简体   繁体   中英

How to add stack-level tags to cloudformation stack deployed using SAM

I'm trying to add tags to a stack while using SAM deploy, but they're not showing up. The SAM cli command code can be found below.

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

Tags are not being created in the CloudFormation stack despite giving the —tag parameter to the cli.

Can someone tell me how to add stack-level tags to the CloudFormation stack that is deployed using SAM CLI?

I'll rather suggest to put them in the samconfig.toml file, like:

[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\""

That will propagate tags down to all the resources of the stack (including CloudFormation stack itself)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM