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: [email protected]: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
2
Answers
You need to Add a service role to build backend.
Here are the steps-
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
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