CloudFormation 堆栈创建后是否可以只添加标签?

Is it possible to just add tags to CloudFormation stack after it is created?

有没有办法只向现有的 CloudFormation 堆栈添加标签? 在更新堆栈操作中,可以指定新标签,但是否可以在不更新的情况下执行此操作(就像 AWS 中的任何其他资源一样)?

不,您不能在不更新堆栈的情况下向现有 CloudFormation 堆栈添加标签。

当您向 CloudFormation 添加新标签时,堆栈将进入 UPDATE_IN_PROGRESS 状态并将新添加的标签更新到堆栈中所有受支持的资源。 Updating/Adding 标签不会替换资源。但是,我建议您在更新之前检查资源标记属性。

希望对您有所帮助!

您可以使用之前的模板创建变更集,查看变更集(仅在变更集的资源描述中注意范围作为标记),然后执行变更集。例如:

aws cloudformation create-change-set --stack-name test--change-set-name test --use-previous-template --parameters file://test.parameters  --tags Key=TestKey,Value=TestValue --capabilities CAPABILITY_IAM

aws cloudformation describe-change-set --stack-name test --change-set-name test

aws cloudformation execute-change-set --stack-name test --change-set-name test