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.
You will need to run amplify push
to generate the aws-exports.js
file, as this is done after the resources are created on AWS.
OK, thanks. Please improve the documentation. It is counterintuitive and I don't see this piece of information in the README.md either.
Hi
Please visit the following link for more detailed documentation:
https://aws-amplify.github.io/amplify-js/media/quick_start?platform=purejs
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.
Thanks for the feedbacks.
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
@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.
@kaustavghosh06 I don't see how my objections were resolved.
@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.
@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.
@jmanek If you look into our AWS Amplify documentation - https://aws-amplify.github.io/docs/cli/init you would observe that there isn't a lot of magic happening with the Amplify CLI. You can notice in the documentation that the CLI uses AWS Cloudformation underneath to create and manage your AWS resources. These Cloudformation files are created for you in your amplify/<category>
directory as a response to you amplify add <category>
command, which in turn gets deployed to the cloud on an amplify push
. If you already have a resource provisioned, and are using the AWS Amplify JS lib, you could manually pass in your resource metadata information to the lib using the Amplify.configure()
method and your frontend could then use an already existing userpool. The Amplify CLI is useful to use for provisioning resources and managing new userpools/identity pools.
@kaustavghosh06 I appreciate the detailed response. My magic comment was only referring to the generation of aws-export.js
during the push
step. But using configure and generating the aws-exports.js
file myself as you suggested seems like the way to go for now.
Edit: confirmed it generates after amplify push
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 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 theandroid
option, then later on when youamplify add auth
andamplify push
, the CLI will not generate anaws-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;
Everything works fine.
In my case, I did it wrong! (Be careful to specify the source folder)
When I have to specify the source folder I put "www" instead of "src".
Because of that I never found the aws-exports.js in the "src" folder.
@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).
Closing this issue for now. Please feel free to re-open this if you have further questions.
@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?
@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?
@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.
@baharev Please use the new install of the CLI. We genarate an aws_exports file on the first amplify init
operation.
@kaustavghosh06 OK, thanks.
@kaustavghosh06 Just tried with the lastest 1.1.5 CLI, did a fresh clone of the repo, amplify init
the master environment, but aws-exports file still not generated. Am I missing any step?
Just tried amplify push
even though amplify status shows no change. I can verify this push does generate the aws-exports file.
@richardzyx Please take a look at my screenshot below.
The aws_exports.js file would be in the directory which you specified as your "Source Directory Path" when you ran an amplify init
.
@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 =]
I tried that as well..see the screenshot below. Is there something different that I shoud try out to reproduce this?
@kaustavghosh06 Hmm interesting, I don't see any difference except here's my output:
As you can see, only amplify push generates the aws-exports.js... let me know if there's anything else you would like me try! I should note that I do have amplify profiles from two different organizations on my laptop, just in case it might be related to this issue.
@kaustavghosh06 any update on this issue?
I had the same issue. What I was doing wrong was when I was setting my source destination during "amplify init", I was giving this "/src". So this is not the correct path as this means the initial destination of your partition, eg: D:/ or C:/.
I update the source destination to "src" only and it works, and now I have aws-export.js file in it.
I had the same issue. What I was doing wrong was when I was setting my source destination during "amplify init", I was giving this "/src". So this is not the correct path as this means the initial destination of your partition, eg: D:/ or C:/.
I update the source destination to "src" only and it works, and now I have aws-export.js file in it.
You can update it using "amplify update project"
@richardzyx did you find your answer? i am also having this issue except the fact is that, aws-exports is not generated on my CI server on amplify init
but on local, it does. i am using amplify cli version 1.1.7
Update:
it seems to run okie on macOS but not on Ubuntu.
it seems like the execution never went past this line on my ubuntu box.
https://github.com/aws-amplify/amplify-cli/blob/b12d20b9d85f7fc6abf7e2f7fbe11e1a108911b9/packages/amplify-cli/src/extensions/amplify-helpers/copy-batch.js#L37
basically whenever it reaches await, it seems that the loop exited. And it seems it only happen on my ubuntu machine but not on my macOS, this is really weird.
@richardzyx it seems that the promise is not resolved correctly but i could not understand why it work on my mac and not on my CI server.
Would appreciate if you could at the same time test my PR https://github.com/aws-amplify/amplify-cli/pull/1028
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.
@chris-merapar I think it will work on node lts/carbon node 8.15.1. Are you using node 10?
Confirmed it works ok with CodeBuild image aws/codebuild/nodejs:8.11.0
Thanks for the tip!
@chris-merapar no prob
It would be good if we can regenerate aws-exports as well, is this possible with the cli?
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.
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.
any updates on this?
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.
@isubasinghe amplify pull
regenerates aws-exports.
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.
While I think it logically makes sense to be able to download the exports file again - it doesn't seem like a high priority to fix.
Note: amplify pull
should be tried first.
The documented bullet proof solution should be:
As you are already logged in on your computer it will ask something like this:
Do you want to use an existing environment? Yes
Choose the environment you would like to use: develop
Choose your default editor: Visual Studio Code
Do you want to use an AWS profile? Yes
Please choose the profile you want to use SELECT PREVIOUS PROFILE
etc...
Having done this you will then need to run amplify pull
again. After that you should be good to go
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.
Most helpful comment
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 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.js
is 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.js
on the first push is confusing, and forces the users to push broken things the first time.