Note: If your question is regarding the AWS Amplify Console service, please log it in the
official AWS Amplify Console forum
* Which Category is your question related to? *
amplify-cli
* What AWS Services are you utilizing? *
amplify/appSync/dynamodb/S3/cognito
* Provide additional details e.g. code snippets *
I try to publish
my amplify project with circle CI.
However It does not succeed with following command
amplify env list
amplify init --amplify "{\"envName\":\"staging\"}" --yes
amplify publish --invalidateCloudFront -- yes
| Environments |
| ------------ |
| dev |
| staging |
Note: It is recommended to run this command from the root of your app directory
Using default provider awscloudformation
For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html
- Initializing your environment: staging
โ Initialized provider successfully.
Could not read cloudformation template at path: /root/app/amplify/backend/api/app/build/cloudformation-template.json
โ An error occurred when pushing the resources to the cloud
โ There was an error initializing your environment.
init failed
{ Error: ENOENT: no such file or directory, open '/root/app/amplify/backend/api/app/build/parameters.json'
at Object.openSync (fs.js:439:3)
at Object.writeFileSync (fs.js:1190:35)
at writeUpdatedParametersJson (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/upload-appsync-files.js:85:8)
at uploadAppSyncFiles (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/upload-appsync-files.js:126:5)
at process._tickCallback (internal/process/next_tick.js:68:7)
errno: -2,
syscall: 'open',
code: 'ENOENT',
path:
'/root/app/amplify/backend/api/app/build/parameters.json' }
Exited with code 1
But it succeed in my local machine with following command.
git clone my-app
cd my-app
amplify env list
amplify init --amplify "{\"envName\":\"staging\"}" --yes
amplify publish --invalidateCloudFront -- yes
However sometimes it succeed with above script in CI ๐ค It's weird...
Do not wait for the file to be generated?
Hi @bokuweb
What's the version of the Amplify CLI you are using? this looks very similar to this issue:
https://github.com/aws-amplify/amplify-cli/issues/1342
Which was fixed and merged by this PR:
https://github.com/aws-amplify/amplify-cli/pull/1383
and published.
@UnleashedMind Oops, I use v1.6.8. Thanks for your information.
@bokuweb We identified the issue and we will submit a fix for it.
Thanks for your great work :)
Thanks @mikeparisstuff. I am hitting the same problem too. What's the best way to go about getting aws-amplify/cli build that has latest fixes?
In my case, I'm using Amplify console, I updated amplify to 1.6.8, but relying on the amplifyPush --simple
script.
I also tried 1.6.9-alpha.2, and amplify console exited after 2019-05-16T00:03:13.650Z [WARNING]: โ Initialized provider successfully.
paused for a minute or two, and then just exited, build failed.
EDIT: This is what finally worked for. Re-run the init for the CI env locally. Then on Amplify console, using @aws-amplify/[email protected].
my backend amplify.yml
build setting is as follows:
backend:
phases:
preBuild:
commands:
- nvm use 10
- npm install -g @aws-amplify/[email protected]
- amplify init --amplify "{\"envName\":\"production\"}" --yes
EDIT: it only worked for the first build, same version failed to build with
```
{ Error: ENOENT: no such file or directory, open '/codebuild/output/src167886779/src/xxxx/amplify/backend/api/consail20graphql/build/parameters.json'
````
This issue is resolved with v1.6.9 ๐ @ronaldwidha If you are ok I'll close this issue.
After much trial and error, I was finally able to get amplify init and publish to work in Github Actions. The method that worked for me as described in #2072 was running the aws cli configure commands to configure the default profile and then using the default profile during amplify init:
name: Continuous Deployment
on:
push:
branches:
- master
paths-ignore:
- 'README.md'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/[email protected]
with:
version: 12.x
- name: Install dependencies
run: |
npm install @aws-amplify/cli -g
npm ci
- name: Verify packages
run: npm run verify-packages
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test
- name: Build project
run: npm run build-prod
- name: Configure amplify
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_KEY }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_KEY }}
aws configure set default.region us-east-1
amplify init --amplify "{\"envName\":\"prod\"}" --providers "{\"awscloudformation\": {\"useProfile\":true, \"profileName\":\"default\"}}" --yes
amplify status
- name: Deploy to production
run: amplify publish --invalidateCloudFront --yes
Note that the ubuntu-latest image comes pre-installed with AWS CLI. I also build my project beforehand separately, with my amplify build command set to echo ๐ Publishing...
Most helpful comment
After much trial and error, I was finally able to get amplify init and publish to work in Github Actions. The method that worked for me as described in #2072 was running the aws cli configure commands to configure the default profile and then using the default profile during amplify init:
Note that the ubuntu-latest image comes pre-installed with AWS CLI. I also build my project beforehand separately, with my amplify build command set to
echo ๐ Publishing...