简体   繁体   中英

set stack level tags in a cloudformation template- not in a nested stack

A little confused about how to do this or if its possible.

THis is not a nested stack. I want to set tags in my CF template that apply to all resources in the template. AWS::CloudFormation::Stack resource can do that, but I don't need/want a nested stack i just have one stack and one template.

Use command deploy with --tags :

aws cloudformation deploy \
   --template-file template.yaml \
   --stack-name MyStack \
   --tags Key1=Value1 Key2=Value2

Docs :

--tags (list) A list of tags to associate with the stack that is created or updated. AWS CloudFormation also propagates these tags to resources in the stack if the resource supports it. Syntax: TagKey1=TagValue1 TagKey2=TagValue2 ...

You can solve that with a kind of a workaround. You can create another CF template that will include only the "AWS::CloudFormation::Stack" resource. In the parameters, provide the tags that you want, and in the "TemplateURL" property, provide the URL of a template that specifies the stack that you want to create as a resource. Note that the template must be stored on an Amazon S3 bucket, so the URL must have the form: https://s3.amazonaws.com/.../TemplateName.extension

For more details: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-templateurl

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