Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-exports.js is not generated #186

Closed
baharev opened this issue Sep 21, 2018 · 48 comments
Closed

aws-exports.js is not generated #186

baharev opened this issue Sep 21, 2018 · 48 comments
Labels
documentation Add or update documentation feature-request Request a new feature

Comments

@baharev
Copy link

baharev commented Sep 21, 2018

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.

@mwarger
Copy link
Contributor

mwarger commented 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.

@baharev
Copy link
Author

baharev commented Sep 21, 2018

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

@UnleashedMind
Copy link
Contributor

UnleashedMind commented Sep 21, 2018

Hi

Please visit the following link for more detailed documentation:

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

@UnleashedMind UnleashedMind added the question General question label Sep 21, 2018
@baharev
Copy link
Author

baharev commented Sep 21, 2018

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.

@UnleashedMind UnleashedMind added the documentation Add or update documentation label Sep 21, 2018
@UnleashedMind
Copy link
Contributor

Thanks for the feedbacks.

@caffodian
Copy link

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
Copy link
Contributor

@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.

@baharev
Copy link
Author

baharev commented Nov 5, 2018

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

@kaustavghosh06
Copy link
Contributor

kaustavghosh06 commented Nov 5, 2018

@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 kaustavghosh06 reopened this Nov 5, 2018
@jmanek
Copy link

jmanek commented Nov 20, 2018

@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.

@kaustavghosh06
Copy link
Contributor

@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.

@jmanek
Copy link

jmanek commented Nov 21, 2018

@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.

@minheq
Copy link

minheq commented Dec 3, 2018

Edit: confirmed it generates after amplify push

@rkuzsma
Copy link

rkuzsma commented Dec 4, 2018

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;

@JrSagas
Copy link

JrSagas commented Dec 17, 2018

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;

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.

@kaustavghosh06
Copy link
Contributor

@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
Copy link
Contributor

Closing this issue for now. Please feel free to re-open this if you have further questions.

@baharev
Copy link
Author

baharev commented Dec 26, 2018

@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?

@kaustavghosh06
Copy link
Contributor

@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?

@baharev
Copy link
Author

baharev commented Dec 27, 2018

@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 kaustavghosh06 added enhancement and removed question General question labels Jan 28, 2019
@kaustavghosh06
Copy link
Contributor

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

@richardzyx
Copy link

richardzyx commented Feb 25, 2019

@kaustavghosh06 Hmm interesting, I don't see any difference except here's my output:

image

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.

@richardzyx
Copy link

@kaustavghosh06 any update on this issue?

@daniyal-intellicel
Copy link

daniyal-intellicel commented Mar 2, 2019

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.

@daniyal-intellicel
Copy link

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"

@roychoo
Copy link
Contributor

roychoo commented Mar 11, 2019

@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.

if (await shouldGenerate(job.target, force)) {

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.

@roychoo
Copy link
Contributor

roychoo commented Mar 12, 2019

@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 #1028

@chris-merapar
Copy link

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.

@roychoo
Copy link
Contributor

roychoo commented Mar 19, 2019

@chris-merapar I think it will work on node lts/carbon node 8.15.1. Are you using node 10?

@chris-merapar
Copy link

Confirmed it works ok with CodeBuild image aws/codebuild/nodejs:8.11.0

Thanks for the tip!

@roychoo
Copy link
Contributor

roychoo commented Mar 19, 2019

@chris-merapar no prob

@isubasinghe
Copy link

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

@jamesw6811
Copy link

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.

@Ecko-oH
Copy link

Ecko-oH commented Aug 31, 2019

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?

@aldrinc
Copy link

aldrinc commented Oct 4, 2019

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.

@collindutter
Copy link

@isubasinghe amplify pull regenerates aws-exports.

@ivenxu
Copy link

ivenxu commented Mar 10, 2020

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.

@danalexilewis
Copy link

danalexilewis commented Apr 13, 2020

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:

  • push up your code to a working branch
  • rm your repo
  • re-clone the repo
  • cd in
  • amplify init

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

@jmcruzmanalo
Copy link

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.

@germanamz
Copy link

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...

@MaxmaxmaximusAWS
Copy link

MaxmaxmaximusAWS commented Apr 15, 2021

amplify is not capable of doing basic things like creating a config file. we have abandoned its use in favor of Microsoft Azure, we wasted our time learning amplify

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2021
@swaminator swaminator reopened this Jun 29, 2021
@swaminator
Copy link
Contributor

swaminator commented Jul 6, 2021

For anyone who lands here, the Amplify console just released a way so that you can autogenerate the aws-exports file at build time without checking it into your git repo: https://docs.aws.amazon.com/amplify/latest/userguide/amplify-config-autogeneration.html

@josefaidt josefaidt added feature-request Request a new feature and removed enhancement labels Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Add or update documentation feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests