How to upgrade CDK bootstrapping?

Viewed 7594

I have an environment which is already bootstrapped, and bootstrapping again (with CDK 1.106.1) doesn't seem to do anything:

$ cdk bootstrap aws://unknown-account/ap-southeast-2
'@aws-cdk/core:newStyleStackSynthesis' context set, using new-style bootstrapping
[…]
 ⏳  Bootstrapping environment aws://unknown-account/ap-southeast-2...
Trusted accounts:   (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.

However, the very next command warns about the bootstrap stack being too old:

$ cdk diff
[…]
Other Changes
[+] Unknown Rules: {"CheckBootstrapVersion":{"Assertions":[{"Assert":{"Fn::Not":[{"Fn::Contains":[["1","2","3"],{"Ref":"BootstrapVersion"}]}]},"AssertDescription":"CDK bootstrap stack version 4 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."}]}}

What gives? I'm already running bootstrap with the latest CDK version. How do I upgrade the bootstrap version?


I've now deleted the "CDKToolkit" stack and re-bootstrapped successfully, but I'm still getting the same warning. What gives? I'm clearly running cdk bootstrap with a recent version of CDK.

I've now filed a CDK issue for this.


Related project issue; build.

3 Answers

Answered by @rix0rrr:

Nothing is actually wrong. The cdk diff is telling you about a Rule that got added to the template, but it doesn't actually know what the Rule means and so is printing it in a confusing way.

The diff will disappear after your next deployment.

I came to this page because I faced an issue related to bootstrap being considered old.

"--cloudformation-execution-policies can only be passed for the modern bootstrap experience."

The below command from the article https://docs.aws.amazon.com/cdk/latest/guide/cdk_pipeline.html was giving me an error. It turned out that export(linux/MacOS) and set(windows) were being mixed in my case.

export CDK_NEW_BOOTSTRAP=1
npx cdk bootstrap aws://315997497220/us-east-1 --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess aws://315997497220/us-east-1

enter image description here

Bootstrapping using AWS profiles also works:

export CDK_NEW_BOOTSTRAP=1
cdk --profile=fortune-dev bootstrap

enter image description here

Related