如何升级 CDK 引导程序?

How to upgrade CDK bootstrapping?

我有一个已经 bootstrapped 的环境,bootstrap再次 ping(使用 CDK 1.106.1)似乎没有做任何事情:

$ 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.

但是,下一个命令警告 bootstrap 堆栈太旧:

$ 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."}]}}

什么给了?我已经 运行 bootstrap 使用了最新的 CDK 版本。如何升级 bootstrap 版本?


我现在已经删除了“CDKToolkit”堆栈并重新bootstrapped 成功,但我仍然收到相同的警告。是什么赋予了?我显然 运行 cdk bootstrap 使用最新版本的 CDK。

我现在已经为此提交了 CDK issue


Related project issue; build.

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.

我来到这个页面是因为我遇到了 bootstrap 被认为是老的问题。

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

文章 https://docs.aws.amazon.com/cdk/latest/guide/cdk_pipeline.html 中的以下命令给我一个错误。事实证明,在我的案例中,export(linux/MacOS) 和 set(windows) 被混合了。

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

使用 AWS 配置文件引导也有效:

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