设置GitLab仓库以在AWS Amplify应用程序中使用Terraform时出现问题。

huangapple go评论62阅读模式
英文:

Issue setting up GitLab repository for AWS Amplify App using Terraform

问题

我在尝试使用Terraform为AWS Amplify App设置我的GitLab存储库时遇到了一个错误。我已经按照必要的步骤进行了操作,但是在terraform apply步骤期间,我一直收到以下错误消息:

Error: creating Amplify App (amplify-test): BadRequestException: There was an issue setting up your repository. Please try again later. ({"message":"403 Forbidden"})

为了提供一些背景信息,我目前正在使用Terraform Registry中的aws_amplify_app资源。我在GitLab中生成了个人访问令牌(PAT)并在设置过程中提供了它,但错误仍然存在。

resource "aws_amplify_app" "example" {
  name       = "example"
  repository = var.gitlabrepo

  # GitHub personal access token
  access_token = "..."
}

我怀疑问题与权限问题或Amplify服务与GitLab之间的授权问题有关。我会感激任何关于如何排除和解决此错误的指导或建议。

以下是我的设置详情:

Amplify App详情:

应用程序名称:amplify-test
存储库提供程序:GitLab
使用的个人访问令牌(PAT):[插入您生成的PAT]
我遵循的步骤:

配置了必要的Terraform代码以供应Amplify App,使用Terraform Registry中的aws_amplify_app资源。
执行了terraform init以初始化Terraform环境。
执行了terraform apply以创建Amplify App。
在terraform apply步骤期间遇到了前述错误。
如果有人遇到类似的问题或对解决此问题有任何见解,请提供帮助,我将不胜感激。提前感谢您的帮助。

我尝试使用Terraform为AWS Amplify App在GitLab上设置我的存储库。我期望存储库设置成功,没有任何错误。然而,当我执行terraform apply命令时,我收到了以下错误消息:

Error: creating Amplify App (amplify-test): BadRequestException: There was an issue setting up your repository. Please try again later. ({"message":"403 Forbidden"})

我在GitLab中生成了个人访问令牌(PAT),并在设置过程中提供了它,期望它能授予必要的权限并解决任何授权问题。不幸的是,错误消息仍然存在,指示为“403 Forbidden”状态。

我还验证了PAT是否具有所需的权限,并遵循了使用Terraform Registry中的aws_amplify_app资源设置Amplify App的推荐步骤。

尽管付出了这些努力,但我仍然无法解决此问题并成功设置Amplify App的存储库。

我将不胜感激任何关于如何排除和解决此错误的见解、建议或指导。谢谢。

英文:

Question:
I am encountering an error while trying to set up my GitLab repository for an AWS Amplify App using Terraform. I have followed the necessary steps, but I keep receiving the following error message during the terraform apply step:

Error: creating Amplify App (amplify-test): BadRequestException: There was an issue setting up your repository. Please try again later. ({"message":"403 Forbidden"})

To provide some context, I am currently using the aws_amplify_app resource from the Terraform Registry. I have generated a personal access token (PAT) in GitLab and provided it during the setup process, but the error persists.

resource "aws_amplify_app" "example" {
  name       = "example"
  repository = var.gitlabrepo

  # GitHub personal access token
  access_token = "..."
}

I suspect that the issue is related to a permission problem or an authorization issue between the Amplify service and GitLab. I would appreciate any guidance or suggestions on how to troubleshoot and resolve this error.

Here are the details of my setup:

Amplify App Details:

App Name: amplify-test
Repository Provider: GitLab
Personal Access Token (PAT) used: [Insert the PAT you generated]
Steps I followed:

Configured the necessary Terraform code for provisioning the Amplify App, using the aws_amplify_app resource from the Terraform Registry.
Executed terraform init to initialize the Terraform environment.
Executed terraform apply to create the Amplify App.
Encountered the aforementioned error during the terraform apply step.
If anyone has encountered a similar issue or has any insights into resolving this problem, I would greatly appreciate your assistance. Thank you in advance for your help.

I tried setting up my repository on GitLab for an AWS Amplify App using Terraform. I expected the repository setup to be successful without any errors. However, when I executed the terraform apply command, I received the following error message:

Error: creating Amplify App (amplify-test): BadRequestException: There was an issue setting up your repository. Please try again later. ({"message":"403 Forbidden"})

I generated a personal access token (PAT) in GitLab and provided it during the setup process, expecting it to grant the necessary permissions and resolve any authorization issues. Unfortunately, the error message persisted, indicating a "403 Forbidden" status.

I have also verified that the PAT has the required permissions and followed the recommended steps for setting up the Amplify App using the aws_amplify_app resource from the Terraform Registry.

Despite these efforts, I have been unable to resolve the issue and successfully set up the repository for the Amplify App.

I would appreciate any insights, suggestions, or guidance to troubleshoot and resolve this error. Thank you.

答案1

得分: 2

经过调查并与AWS支持团队交流,不幸的是,默认情况下,AWS Amplify不支持通过Terraform集成Gitlab仓库,因为GitLab支持仓库镜像,而Amplify支持AWS CodeCommit,这是AWS的源代码版本控制系统。

作为一个建议的解决方法,您可以将您的GitLab仓库镜像到AWS CodeCommit。通过这样做,您在GitLab上进行的任何推送都将自动同步到CodeCommit,用于相应分支的更改,并触发Amplify应用程序进行构建或重新构建。
参考链接:

https://docs.gitlab.com/ee/user/project/repository/mirror/push.html#set-up-a-push-mirror-from-gitlab-to-aws-codecommit

https://github.com/aws-amplify/amplify-hosting/issues/14

英文:

after investigation and talking with aws support, unfortunately, by default, AWS Amplify does not support integrating the Gitlab repository via Terraform since GitLab supports repository mirroring and Amplify supports AWS code commit which is AWS's source code versioning system.

As a suggested workaround, you can mirror your GitLab repository to AWS CodeCommit. By doing this, any pushes you make to GitLab will automatically synchronize your changes to CodeCommit for the corresponding branches and trigger the Amplify App to build or re-build.
Reference;

https://docs.gitlab.com/ee/user/project/repository/mirror/push.html#set-up-a-push-mirror-from-gitlab-to-aws-codecommit

https://github.com/aws-amplify/amplify-hosting/issues/14

huangapple
  • 本文由 发表于 2023年7月13日 19:16:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678751.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定