如何向使用 SAM 部署的 cloudformation 堆栈添加堆栈级标签

Dev*_*Dev 3 amazon-web-services aws-sam-cli aws-serverless

我尝试在使用 SAM 部署时向堆栈添加标签,但它们没有显示。\n可以在下面找到 SAM cli 命令代码。

\n
sam deploy --stack-name test-stack --resolve-image-repos --capabilities CAPABILITY_NAMED_IAM --no-fail-on-empty-changeset --template-file ./.aws-sam/build/template.yaml --resolve-s3 --tags Name=test-stack az:zone=infra\n
Run Code Online (Sandbox Code Playgroud)\n

尽管向 cli 提供了 \xe2\x80\x94tag 参数,但 CloudFormation 堆栈中并未创建标签。

\n

有人可以告诉我如何将堆栈级标签添加到使用 SAM CLI 部署的 CloudFormation 堆栈吗?

\n

Leo*_*ela 6

我宁愿建议将它们放入文件中samconfig.toml,例如:

[default.deploy.parameters]
stack_name = "your-application"
s3_bucket = "your-s3-for-cloudformation-stuff"
s3_prefix = "your-folder-name"
...
tags = "Name=\"test-stack\" az:zone=\"infra\""
Run Code Online (Sandbox Code Playgroud)

这会将标签传播到堆栈的所有资源(包括 CloudFormation 堆栈本身)