amplify-cli: aws-exports.js is not generated

I created a new hello world app with create-react-app. Followed the instructions on https://github.com/aws-amplify/amplify-cli and added auth and hosting to my hello world react app. The amplify cli did not report any errors, but reported OK. As far as I can tell all the necessary files were created by the amplify cli in the amplify subdirectory of the project. amplify status does show Auth. Everything looks OK except that the aws-exports.js is nowhere to find in the entire project folder.

Repeated the whole thing again, with the same result.

Everything is at the latest version as of Sep 21, 2018.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 48 (17 by maintainers)

Most upvoted comments

Even after the third read I find it utterly confusing, and I have usability issues too.

Why should I push something that I could not have run locally? It is untested and most likely buggy but I cannot run npm start to test it without the aws-exports.js.

In other words, on the first push, I would have to push something that is most likely broken because it has never been run (but I cannot run it).

I also find the https://aws-amplify.github.io/amplify-js/media/quick_start?platform=purejs page utterly confusing. aws-exports.js is only mentioned at amplify push, right above it I read: “Create the AWS backend resources and update the aws-exports.js file.” This sentence tells me that this file already exists, since it is being updated. And that would be my expectation too. I would expect this file to be complete after amplify init (or maybe after the first add) has finished.

Generating aws-exports.js on the first push is confusing, and forces the users to push broken things the first time.

Hi

Please visit the following link for more detailed documentation:

https://aws-amplify.github.io/amplify-js/media/quick_start?platform=purejs

OK, thanks. Please improve the documentation. It is counterintuitive and I don’t see this piece of information in the README.md either.

@isubasinghe amplify pull regenerates aws-exports.

I faced the same issue. In my case, when prompted during amplify init with the following choice:

Choose the type of app that you're building (Use arrow keys)
  android
  ios
❯ javascript

Make sure to choose javascript. If you choose the android option, then later on when you amplify add auth and amplify push, the CLI will not generate an aws-exports.js file.

Here is what my generated aws-exports.js file contains (actual ID’s redacted by me):

const awsmobile =  {
    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:REDACTED",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-1_REDACTED",
    "aws_user_pools_web_client_id": "REDACTED"
};
export default awsmobile;

I’m having a similar issue where even after init, recreating storage/auth resources, and pushing, I still don’t have an aws-exports.js generated.

When I init’ed the project i chose:

➜  ✗ amplify init
Note: It is recommended to run this command from the root of your app directory
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react-native
? Source Directory Path:  /
? Distribution Directory Path: /
? Build Command:  npm run-script build
? Start Command: npm run-script start

and when I pushed, it created auth/storage resources correctly, as well

@kaustavghosh06 I don’t see how my objections were resolved.

The aws-exports.js is in .gitignore file and the only ways to generate are so heavy. It’s a must-have that lightweight cli option to just generate the aws-exports.js.

It would be good if we can regenerate aws-exports as well, is this possible with the cli?

What is the recommended approach for handling this issue in a CI env?

I’m using MS Appcenter for my builds and its failing because aws-exports.js is missing. I am unable to generate the aws-exports.js file via amplify push as it says no change. I’m on node v12.4.0.

On my mac and in CodeBuild the aws-exports.js is not generated:

  1. Delete src/aws-exports.js (thereby simulating the CI env, as this is in the gitignore)
  2. amplify init
  3. amplify push (reports no changes, so does not do anything)
  4. amplify publish

No src/aws-exports is generated. I am on amplify CLI v1.1.7.

Does anyone have a workaround? Right now all our environments are broken as the aws-exports is not generated. Adding it to git won’t help as it will be wrong for all our cloud envs.

@kaustavghosh06 I would like to test my own client-side code, which imports aws_exports.js. Note that the code would run just fine without any AWS resource being available but it needs the aws_exports.js or the npm start call fails. Without the aws_exports.js, I have to push a most likely broken code on the first push to get the aws_exports.js. This is just wrong.

@kaustavghosh06 Once again, I don’t see how my objections were resolved. In reply to your earlier comment: Who said that I want to test my AWS resources? And why would I want to test AWS?

@rkuzsma For android projects, the CLI generates an awsconfiguration.json file (in the app directory) and not an aws_exports.js file ( which is generated only for javascript projects).

@kaustavghosh06 I found this issue for the same reasons @baharev did.
If new resources need to be provisioned then obviously init is not enough and push is just not a clear name. However I am working with existing AWS resources. So for example I want the “template” for Cognito authentication so I can replace the values with my own and not rely on magic. It seems like I am actually expected to allocate an entirely new pool just to get this single config file that contains no config I actually need. I just want the key names. If there were defined steps to integrate Amplify into an existing production environment it would go a long way for someone like me.

Just in case it helps someone I did all the above steps but turns out .gitignore is updated to ignore aws-exports.js. VSCode’s quick open did not show this file to me, so in my case, it was already there I just didn’t know. After opening it once it seems to show up normally.

@baharev Please use the new install of the CLI. We genarate an aws_exports file on the first amplify init operation.

@baharev There is no way to locally test your AWS resources without pushing it. So I’m not sure what would you test with an empty aws_exports.js file without actually pushing your resources.

So… The problem with removing the aws-exports.js from the .gitignore is that you’ll need to generate configurations each time you want to deploy to different envs… so my suggestion is to use a custom build image that should do the amplify pull to generate the file.

I think this should be included somehow on the default build image as Amplify is supposed to support different environments and we aren’t able to build the apps properly because of this missing file.

NOTE: I think this is a major issue that’s making me reconsider using Amplify…

It would be good if we can regenerate aws-exports as well, is this possible with the cli?

Agree. I have found my aws-exports does not always update, especially if I delete resources then init a new project. It will be stuck without updating to the new resources. It would be good to be able to do a complete project update/overwrite.

@kaustavghosh06 Thanks for the prompt reply!

I believe the screenshot shows the use case of creating a new environment through Amplify init which does work properly. My use case was cloning an amplify project on a fresh machine and trying to regenerate the aws-exports file on the master branch & environment after a new amplify profile is setup. In this case, only amplify push will regenerate the aws-exports file =]

@baharev I’m not clear as to what you’re advocating here. If you do not want to test AWS, why would you want the aws_exports.js file in the first place?

@caffodian I couldn’t reproduce the issue with the latest version of the CLI. Many a times VS code bugs out and doesn’t sync with my local filesystem to display the newly created files. Closing this issue for now. Please let me know if you’re able to re-produce this with he latest version of the CLI.