Describe the bug
I re-created dev environment using amplify cli and when i pushed the changes, amplify console was picking old stackInfo from envCache. I can't find any documentation of how to prevent using old cached values. Below are the logs:-
logs
//Getting Amplify CLI Cloud-Formation stack info from environment cache
2019-03-27T13:32:53.066Z [INFO]: # Start initializing Amplify environment: dev
2019-03-27T13:32:53.068Z [INFO]: STACKINFO={
"awscloudformation": {
"AuthRoleName": "old-authRole",
"UnauthRoleArn": "arn:aws:iam::old-unauthRole",
"AuthRoleArn": "arn:aws:iam::old-authRole",
"Region": "us-east-1",
"DeploymentBucketName": "old-deployment",
"UnauthRoleName": "old-unauthRole",
"StackName": "old",
"StackId": "arn:aws:cloudformation:us-east-1:227484579606:stack/old"
},
"categories": {
"auth": {
"cognitols": {}
}
}
}
// Importing Amplify environment: dev (amplify env import)
2019-03-27T13:32:55.802Z [INFO]: Successfully added environment from your project
2019-03-27T13:32:55.809Z [INFO]: # Initializing existing Amplify environment: dev (amplify init)
2019-03-27T13:32:57.242Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2019-03-27T13:32:58.538Z [WARNING]: - Initializing your environment: dev
2019-03-27T13:32:58.612Z [WARNING]: ✖ There was an error initializing your environment.
2019-03-27T13:32:58.613Z [INFO]: init failed
2019-03-27T13:32:58.616Z [INFO]: { NoSuchBucket: The specified bucket does not exist
@artista7 Hi, you can add -envCache --set stackInfo '' in the build spec, which will reset the envCache.
The example buildSpec looks like:
version: 0.1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- envCache --set stackInfo ""
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: build
files:
- '/'
cache:
paths:
- node_modules//
Closing for now, comment on this if you still have the problem, we can re-open it.
Cool. Let me try
Please add this to the documentation, I got bitten by this too and it wasn't at all clear how to clear the cache.
@garyleefight Hi, can you update your comment to use markdown code format?
It's kind of hard to read in the above format. Thanks for the info, it helps a lot!
@dabit3 Here's my amplify.yml contents in md. not saying it's correct. But I remember I had set envCache --set stackInfo "" once in the past when having issues. I then change that line to '# envCache --set stackInfo ""' when I want to allow the stackInfo to come from the cache.
version: 0.1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- envCache --set stackInfo ""
- amplifyPush --environment $USER_BRANCH --simple
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Most helpful comment
The example buildSpec looks like:
version: 0.1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- envCache --set stackInfo ""
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: build
files:
- '/'
cache:
paths:
- node_modules//