AWS amplify deploy failure due to aws-exports AWS amplify deploy failure due to aws-exports reactjs reactjs

AWS amplify deploy failure due to aws-exports


I have experienced the same problem in my first build. Since aws-exports contains sensitive information you are right by adding it to your .gitignore file.

The Amplify documentation is not specific about how you should maintain your builds when using the Amplify Console, but the routine that worked for me was:

You generate your aws-exports file when you run a successful amplify push command.

aws-exports.js fileThis file is generated only for JavaScriptprojects. It contains the consolidated outputs from all the categoriesand is placed under the src directory that the user (the developer)specified during the init process. It is updated after each successfulexecution of the amplify push command, that has created or updated thecloud resources.

Based on that I updated my configuration in the Amplify console to also deploy my backend. You can learn how to configure your own at https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html

backend:  phases:    build:      commands:        - '# Execute Amplify CLI with the helper script'        - amplifyPush --simple

After the backend build is done the file is generated for my next job which is the frontend build that consumes the aws-exports file.

Note: If you're using eslint you can have a problem with the file output format. You can add a eslint --fix command in your frontend preBuild

Update: As lucdenz mentioned, you also need to setup a service role

Sources I used: