I’m deploying a stack using AWS CDK. I’ve successfully bootstrapped the environment with a new S3 bucket and a new qualifier (sandbuck2), but during deployment, CDK keeps referencing the old bootstrap qualifier (hnb659fds) and fails with the following error:
SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
The old qualifier (hnb659fds) was used in a previous bootstrap, but I’ve since bootstrapped the environment with a new bucket and qualifier (sandbuck2). Despite confirming that the new SSM parameter for the new qualifier exists, CDK is still referencing the old SSM parameter.
1.Bootstrapped a new environment with the following command:
cdk bootstrap --bootstrap-bucket-name cdk-bootstrap-assets-975049968143-ap-south-1-sandbucket2
--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
--qualifier sandbuck2
aws://975049968143/ap-south-1 --force
2.Cleared the CDK context using:
cdk context --clear
3.Deleted the cdk.context.json file from the project directory.
4.Checked the SSM parameters:
The new SSM parameter /cdk-bootstrap/sandbuck2/version exists.
There is no /cdk-bootstrap/hnb659fds/version in the parameter store.
5.Searched my entire project for any hardcoded references to hnb659fds and replaced them with sandbuck2. No references to the old qualifier remain in the code.
6.tried adding synthesizer in the code with bucket name and qualifier
7.Tried re bootstrapping it says se bucket already exists and fails
2
Answers
hnb659fds
is the default qualifier. To let your CDK code know that you’ve bootstrapped with a different one, you need to either pass to your stacks a custom instance ofDefaultSynthesizer
with thequalifier
set to your string using thesynthesizer
prop, or set the@aws-cdk/core:bootstrapQualifier
context variable to your custom qualifier.Option 1:
Option 2:
add the following to your
cdk.json
object:cdk deploy
is a finnicky command with cache issues, it appears.Try these two command formats (you may add more flags):
and
The latter is just a one-time filler for
cdk.json
. You can confirm whether yourcdk.json
context values are actually being loaded by runningcdk context
. Note that the output is not in the same order ascdk.json
file.In my use case with CodeBuild, I had to use both flags.