-
Notifications
You must be signed in to change notification settings - Fork 821
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
How to generate aws-exports.js file? #3643
Comments
There's no such a command that solely generates the aws-exports.js file. |
Ok thanks. It's just confusing what amplifyPush does in the AWS Amplify Console CI/CD build. For example, if branch A and branch B are connected to backend env 'prod'. Let's say in branch A I make a change to the backend and push via 'amplify push' on my computer but I don't git push. Then in branch B I make a frontend change and git push, but branch B has old prod environment since it's not merged with branch A. What will amplifyPush in AWS Amplify do? Will it override the backend prod env with an older version or is it smart enough to not revert. It's not clear. It seems to run an 'amplify init' command which may or may not push. I guess I'll do more testing and reading. |
@hisham You can also just use the command |
@kaustavghosh06 I just tried this by adding it in my prebuild step for frontend in amplify.yml Snippet from my amplify.yml:
|
I guess my use case is how do I connect a frontend with a backend in the AWS Amplify CI environment without triggering an amplify push? It seems the current amplifyPush.sh script can trigger a push even though it only calls |
How about |
Also, you can execute this command in a headless manner in your CI scripts - https://aws-amplify.github.io/docs/cli-toolchain/usage#amplify-pull-parameters |
Please comment on this thread if you have any further questions |
I am trying to achieve this, I need aws-exports to be generated before pushing because I need some values to generate a dotenv file being used by some of my lambda functions, I need to do that on amplify ci/cd. I tried
When I used
Any thoughts on how to do this? -- Edit Also tried I tried
this is my amplify.yml version: 0.1
backend:
phases:
build:
commands:
- npm ci
- amplify env checkout $AWS_BRANCH
- npm run gen-lambda-vars
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- $HOME/.npm |
Does anyone have an example using |
Please don't take offence but this response is typical of AWS docs - note this line: "...and also recreate the aws-exports.json file for you..." and then this one: "...absolutely have to manually construct the aws-exports.js file..." So what is it that gets created ? A JSON file or a JS file ? And what does 'amplify pull' do ? Either way I don't get any aws-exports.js or aws-exports.json created locally in the /src folder (or anywhere else for that matter). ?? |
amplify env checkout demo does not recreate the aws-config.js file nor do any of the other amplify pull commands!! Also why does my original aws-exports.js file have const awsmobile = {...} That's clearly going to fail when the frontend is deployed because the deployment relies on importing config ? |
for other people running into similar issues, i fixed this problem by creating my own config file:
i have .env file for different environments. e.g.
and i also set the environment on amplify build settings for each environment individually using BUILD_ENV, here is my amplify.yml file
package.json
|
If anyone is stuck with version: 1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple'
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run generate
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/* |
https://console.aws.amazon.com/iam/home?region=us-west-1#/roles
https://us-west-1.console.aws.amazon.com/amplify/home?region=us-west-1#/ ... /settings/build
|
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 |
As a follow-up on this, to generate the aws-exports.js file in an existing project (or checkout a backend environment that exists in the console but does not show up locally), follow these steps:
|
Since then we have launched capabilities for you to generated the aws-exports.js in the build container as well: https://docs.aws.amazon.com/amplify/latest/userguide/amplify-config-autogeneration.html (for anyone who lands here) |
** Please describe which feature you have a question about? **
Is there a way to generate the aws-exports.js file that amplify cli generates without running amplifyPush or doing any kind of change to the existing backend env? There must be a command for that.
** Provide additional details**
Due to aws-amplify/amplify-hosting#501, my backend build in AWS Amplify is failing. I don't need to make changes to the backend however through AWS Amplify. The only reason I am running amplifyPush is so that aws-exports.js is generated, which is needed by my frontend.
The text was updated successfully, but these errors were encountered: