Here's how I'm instantiating my stack:
new LambdaStack(new App(), 'LambdaStack', {
env: { account: AWS_ACCOUNT_ID, region: 'us-east-1' },
synthesizer: new DefaultStackSynthesizer({
qualifier: 'lambda-stk',
}),
stackName: 'LambdaStack',
});
First I ensure that my ~/.aws/credentials
file has the correct credentials. Then I bootstrap:
npx cdk bootstrap --qualifier lambda-stk --toolkit-stack-name LambdaStack aws://ACCOUNT_ID_HERE/us-east-1
Everything looks good in the console. Then, I deploy:
npx cdk deploy --require-approval never
Everything still looks good in the console -- the lambdas have been created as I expected, etc.
Then, I simply run the same deploy command again without changing anything and I get this error:
LambdaStack failed: Error: LambdaStack: SSM parameter /cdk-bootstrap/lambda-stk/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
Upon further investigation, it seems that the bootstrap command properly creates the referenced SSM parameter but then the first deploy command deletes that parameter. Why would it do that and how can I fix this problem?
Fixed it by naming the bootstrap stack something different from LambdaStack
. I was under the impression that the bootstrap command was spinning up the stack that the "main" stack would use, but actually it's a completely different stack. So I changed the bootstrap command to:
npx cdk bootstrap --qualifier lambda-stk --toolkit-stack-name LambdaStackCDKToolkit aws://ACCOUNT_ID_HERE/us-east-1
And it worked.