skip to Main Content

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


  1. 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 of DefaultSynthesizer with the qualifier set to your string using the synthesizer prop, or set the @aws-cdk/core:bootstrapQualifier context variable to your custom qualifier.

    Option 1:

    const myCustomSynthesizer = new new DefaultStackSynthesizer({
        qualifier: 'sandbuck2',
    });
    
    new Stack(app, 'MyStack', {
        synthesizer: myCustomSynthesizer
    });
    

    Option 2:

    add the following to your cdk.json object:

    "context": {
        "@aws-cdk/core:bootstrapQualifier": "sandbuck2",
    }
    
    Login or Signup to reply.
  2. cdk deploy is a finnicky command with cache issues, it appears.

    Try these two command formats (you may add more flags):

    cdk deploy --no-previous-parameters
    

    and

    cdk deploy --context @aws-cdk/core:bootstrapQualifier=sandbuck2
    

    The latter is just a one-time filler for cdk.json. You can confirm whether your cdk.json context values are actually being loaded by running cdk context. Note that the output is not in the same order as cdk.json file.

    In my use case with CodeBuild, I had to use both flags.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search