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)
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 startto test it without theaws-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.jsis only mentioned atamplify 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 afteramplify init(or maybe after the firstadd) has finished.Generating
aws-exports.json 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 pullregenerates aws-exports.I faced the same issue. In my case, when prompted during
amplify initwith the following choice:Make sure to choose
javascript. If you choose theandroidoption, then later on when youamplify add authandamplify push, the CLI will not generate anaws-exports.jsfile.Here is what my generated
aws-exports.jsfile contains (actual ID’s redacted by me):I’m having a similar issue where even after init, recreating storage/auth resources, and pushing, I still don’t have an
aws-exports.jsgenerated.When I init’ed the project i chose:
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:
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 startcall 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.jsonfile (in the app directory) and not anaws_exports.jsfile ( 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
initis not enough andpushis 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
.gitignoreis updated to ignoreaws-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 initoperation.@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.jsfrom the.gitignoreis 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 theamplify pullto 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…
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.