AWS access credentials can not be found error – when deploying on Amplify

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

AWS access credentials can not be found error - when deploying on Amplify

问题

我正在尝试在Amplify上部署我的React应用程序。我正在使用存储、身份验证和GraphQL API。但在推送代码时出现了此错误。构建失败。

当在本地主机上运行时,一切都按预期工作。

我尝试过使用amplify configure重新配置,还尝试过重新连接GitHub,但都没有起作用。

请问您能帮助吗?谢谢!

英文:

I'm trying to deploy my react app on amplify. I'm using Storage, Authentication and GraphQL API. But I'm getting this error when pushing the code. Build is failing.

Everything works as expected when running on local host.

2023-05-20T09:21:17.184Z [INFO]: # Cloning repository: git@github.com:zyz/xyz
2023-05-20T09:21:19.101Z [INFO]: 
2023-05-20T09:21:19.103Z [INFO]: Cloning into 'zeeepy'...
2023-05-20T09:21:19.104Z [INFO]: # Switching to commit: bd45c7afa30c9e71643a0e0a2991d0fc8440c7aa
2023-05-20T09:21:19.124Z [INFO]: Note: switching to 'bd45c7afa30c9e71643a0e0a2991d0fc8440c7aa'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at bd45c7a Backend integrated
2023-05-20T09:21:19.180Z [INFO]: Successfully cleaned up Git credentials
2023-05-20T09:21:19.180Z [INFO]: # Checking for Git submodules at: /codebuild/output/src242373753/src/zeeepy/.gitmodules
2023-05-20T09:21:19.189Z [INFO]: # Retrieving environment cache...
2023-05-20T09:21:19.796Z [INFO]: # Retrieved environment cache
2023-05-20T09:21:19.797Z [INFO]: ---- Setting Up SSM Secrets ----
2023-05-20T09:21:19.797Z [INFO]: SSM params {"Path":"/amplify/d3ia74jrzqfroo/main/","WithDecryption":true}
2023-05-20T09:21:19.836Z [WARNING]: !Failed to set up process.env.secrets
2023-05-20T09:21:42.406Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 10.5.2 to 12.0.0...
2023-05-20T09:22:02.567Z [INFO]: # Done patching NPM package '@aws-amplify/cli' to version 12.0.0
2023-05-20T09:22:02.630Z [INFO]: # Retrieving cache...
2023-05-20T09:22:05.748Z [INFO]: # Extracting cache...
2023-05-20T09:22:10.438Z [INFO]: # Extraction completed
2023-05-20T09:22:11.441Z [INFO]: # Retrieved cache
2023-05-20T09:22:15.475Z [INFO]: ## Starting Backend Build
                                 # Starting phase: build
2023-05-20T09:22:17.637Z [INFO]: [33mNote: It is recommended to run this command from the root of your app directory[39m
2023-05-20T09:22:17.652Z [INFO]: 🛑 AWS access credentials can not be found.
2023-05-20T09:22:17.652Z [INFO]: Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
2023-05-20T09:22:17.696Z [INFO]: 
2023-05-20T09:22:17.697Z [INFO]: Session Identifier: 5668b0c6-8dc5-4dcd-8b00-38754fa06b84
2023-05-20T09:22:17.715Z [ERROR]: !!! Build failed
2023-05-20T09:22:17.716Z [ERROR]: !!! Non-Zero Exit Code detected
2023-05-20T09:22:17.716Z [INFO]: # Starting environment caching...
2023-05-20T09:22:17.716Z [INFO]: # Uploading environment cache artifact...
2023-05-20T09:22:17.824Z [INFO]: # Uploaded environment cache artifact
2023-05-20T09:22:17.824Z [INFO]: # Environment caching completed
Terminating logging...

I tried to reconfigure using amplify configure and also tried to reconnect with github. Nothing is working.

Could you please help?

Thanks & Regards

答案1

得分: 5

你需要为构建后端添加一个服务角色。

以下是步骤-

  1. 转到 IAM 管理器
  2. 在左侧导航栏中点击 ROLES
  3. 点击创建角色
  4. 在角色选择屏幕中找到 Amplify 并选择 Amplify-Backend Deployment 角色。接受所有默认设置并选择一个名称,例如 AmplifyConsoleServiceRole-AmplifyRole
  5. 转到 Amplify 控制台
  6. 选择你的应用程序
  7. 在右上角点击 查看应用程序设置
  8. 点击编辑
  9. 在服务角色下拉菜单中选择你刚刚创建的后端角色
  10. 保存并重新运行构建。

应该可以工作。
这是 AWS 文档供参考- https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html#step-3-return-to-the-amplify-console

英文:

You need to Add a service role to build backend.

Here are the steps-

  1. Go to IAM manager
  2. Click on ROLES in the left Navigation bar
  3. Click on Create Role
  4. In the role selection screen find Amplify and choose the Amplify-Backend Deployment role. Accept all the defaults and choose a name for your role, such as AmplifyConsoleServiceRole-AmplifyRole.
  5. Go to Amplify Console
  6. Select your app
  7. Go to View App Settings in the top right corner
  8. Click on Edit
  9. Under Service Role dropdown-select the backend role you just created
  10. Save and re-run the build.

It should work.
Here's the AWS documentation for reference- https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html#step-3-return-to-the-amplify-console

答案2

得分: 1

Your amplify configuration lacks the required IAM permissions.
Follow this guide to create the required role for Amplify -> https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html#step-3-return-to-the-amplify-console

英文:

It seems that your amplify configuration lacks the required IAM permissions.

Follow this guide to create the required role for Amplify -> https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html#step-3-return-to-the-amplify-console

huangapple
  • 本文由 发表于 2023年5月21日 01:54:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76296636.html
匿名

发表评论

匿名网友

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

确定