aws-cdk: cdk 2.1.0 synth, diff subcommands fail with "AssertDescription: CDK bootstrap stack version 6 required...". cdk 2.1.0 deploy subcommand succeeds.
What is the problem?
cdk synth and cdk diff fail with “AssertDescription: CDK bootstrap stack version 6 required. Please run ‘cdk bootstrap’ with a recent version of the CDK CLI.” after the template checks SSM for version not 1-5. The actual version in SSM is 9.
cdk deploy succeeds.
After the successful cdk deploy, the synth and diff continue to fail.
Reproduction Steps
- Upgrade cdk 2.0.0 to 2.1.0
- run cdk bootstrap with appropriate credentials
- create a new folder and cd to it
- create a new cdk project with
cdk init --language typescript - cdk synth
- cdk diff
- cdk deploy
What did you expect to happen?
A clean synth with no errors displayed A clean diff with no errors displayed A clean deploy with no errors displayed
What actually happened?
for synth and diff
...
Rules:
CheckBootstrapVersion:
Assertions:
- Assert:
Fn::Not:
- Fn::Contains:
- - "1"
- "2"
- "3"
- "4"
- "5"
- Ref: BootstrapVersion
AssertDescription: CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.
for deploy - a clean, error-free execution with a CFn template produced as expected.
CDK CLI Version
2.1.0
Framework Version
2.0.0
Node.js Version
16.10.0
OS
macOS Monterey (12.0.1)
Language
Typescript
Language Version
TypeScript 4.2.4
Other information
The bootstrap CDKToolkit stack looks as expected - all of the modern template trappings (the previous bootstrap was legacy). The value of the SSM parameter /cdk-bootstrap/hnb659fds/version is 9, as expected. The cdk-hnb659fds-deploy-role-<account>-<region> role has the appropriate ssm:GetParameter permission for …/cdk-bootstrap/hnb659fds/version. the cdk-hnb659fds-lookup-role-<account>-<region> role has ssm:Get* permission for *.
“old” cdk projects continue to function as expected with cdk synth etc.
Hoping you can deduce some bozo thing I must have overlooked or done. Thanks for whatever help you can provide.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 34 (9 by maintainers)
Links to this issue
Commits related to this issue
- added temp workaround https://github.com/aws/aws-cdk/issues/17942 — committed to aldomatic/fastify-aws-cdk by aldomatic a year ago
IF YOU ARE COMING HERE AND STILL NOT UNDERSTANDING THIS THREAD (because you scrolled too fast, like me, and missed @chesterm8’s write up)
This is NOT an error. YOUR CODE IS FINE.
The cdk synth step creates a number of resources for your app. One of those resources is a check that the deploying tool has the correct version. This is an error that would happen, IF you ran
cdk deploywith an out-of-date bootstrap. The AssertDescription would then be the error shown at that point.This is a “UX” bug because it happens to be the last thing in the diff for the stack after synth, and it catches you unaware and takes a minute to parse out.
There is an “easy” fix - print “CDK synth succeeded” on stderr and exit 0 as the last step of synth.
This is a pretty confusing thing to see when just starting with CDK. I get it now, but I would still consider it a UX bug.
As per the comment above https://github.com/aws/aws-cdk/issues/17942#issuecomment-992295898 this is not a bug/issue that needs to be fixed or worked around. The text being seen is the error message that would get printed if there were a CDK version issue. You are seeing it because you have printed out the contents of your CF stack and it is stored in there as a string.
It is very clearly a confusing UX situation that should be resolved, but you don’t need to start turning off CDK features to get rid of this part of your CDK stack.
I just had a fresh install of
aws-cdk 2.25.0fromcdk init app --language typescriptconfirmed problem still exist.from @njlynch’s comment https://github.com/aws/aws-cdk/issues/17942#issuecomment-992295898
For the assertion issue also happen in
cdk synth. So it is impossible to do the first deploy before I want to confirm what to be deployed by studying the output ofcdk synth(synthesized CloudFormation template).Workaround for typescript
For those who want to check the result before the first deploy, I suggest to temporarily add
"@aws-cdk/core:newStyleStackSynthesis": falsein yourcdk.jsonAfter that, I can get the output
Allow me to communicate that this “error”, has wasted many valuable minutes of my life.
CDK v2 enables the “new-style stack synthesizer” by default (e.g.,
DefaultStackSynthesizer), which was previously enabled for v1 by setting the@aws-cdk/core:newStyleStackSynthesisfeature flag. The DefaultStackSynthesizer uses conventionally named roles and concrete asset storage locations, versus theLegacyStackSynthesizer, which has restricted cross-environment abilities and uses CloudFormation parameters for assets.With the default synthesizer, the
CheckBootstrapVersionrule is added to the Stack’s template as a safety check, to verify that the bootstrap stack in the target environment meets the minimum requirements of the current stack. TheAssertDescriptionbeing shown is the failure message a user would see on deploy if their bootstrap stack was not up-to-date. The inclusion of this element is not a failure, merely a new element for stacks that are being upgraded from the legacy synthesizer. It will show up in thediffuntil it is deployed, and then will only show up if there’s a change, same as any other CloudFormation template element.Hope that helps! Let me know if you have any follow-ups on that.
Hahaha this is a very weird things. It took me some time to realize it wasnt an error and merely an attribute value. I highly recommend it not being the last line on the console
This is very confusing. I’ve read through the thread and here is what I think I’ve learned. Please correct me if I’m wrong.
The message
Please run 'cdk bootstrap' with a recent version of the CDK CLI.in the output is not a warning or error being generated as a result of the command being run currently. Instead it is the content of an assertion that is being added to the stack to detect potential problems in the future. So in the future if an out-of-date version is detected, this message will be shown.same here, created new stack and seeing this warning is weird dev experience.
One more necrobump… I had “this problem” with a pipelines stack that worked from from cli cdk deploy. In this case, the cdk project was in a subdirectory of the project and while I was building fine because I included in the commands
cd cdk-dirI forgot to update theprimaryOutputDirectoryas well and overlooked the reason the build was failing.cdk deployis helpfully printing the error message it would have printed had there actually been an error? That’s very, um, proactive?There is an ‘easier’ fix - For AWS to stop publishing tools that mislead and confuse, and to do the job that all AWS customers pay them for.
@robertd thanks. My issue is that the feature seems not to be working correctly. The version check is “bootstrap version is not 1, 2, 3, 4, 5”, i.e. version is >= 6. My bootstrap version is 9 (verified by inspecting the SSM parameter …/cdk-bootstrap/hnb659fds/version). So I should pass this check. But I am failing it. So the cdk variable “BootstrapVersion” that synch is checking must have the value 1, or 2, or 3, or 4, or 5. That value would be wrong.
Does that make sense? Thanks.
This documentation needs to be updated to reflect the actual user experience. https://docs.aws.amazon.com/cdk/v2/guide/hello_world.html
2024 and i just got the “error” and came here to understand how it works LOL
I see it’s not an error now - but it is really confusing! Hopefully AWS will fix this one day…
Why not just fix the UX issue?