简体   繁体   中英

Tag the parent stack from a CloudFormation template

Is there a way to create tags on a CloudFormation stack from the template itself? (the parent stack, not nested stacks)

We have many templates, which get updated with each new version of software. Our software versions are tagged (in git), and it would be nice to see at a glance which version a particular stack was spooled up with.

The top-level anatomy of a template specifies 6 nested sections:

{
  "AWSTemplateFormatVersion" : "version date",

  "Description" : "JSON string",

  "Metadata" : {
    template metadata
  },

  "Parameters" : {
    set of parameters
  },

  "Mappings" : {
    set of mappings
  },

  "Conditions" : {
    set of conditions
  },

  "Resources" : {
    set of resources
  },

  "Outputs" : {
    set of outputs
  }
}

But none of those sections seem to allow for the tagging of the stack itself (hopefully I am missing something here).

Yes, I could add a version string to the Metadata section, and that could be viewed by looking at the template for a particular stack, but tags are so much easier to work with in AWS. Plus it would allow much easier control over who can update/delete the stack.

At the moment we do not make much use of stack tags because of this limitation.

This looks promising:

http://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html

  create-stack
--stack-name <value>
...
[--tags <value>]
...

I think I've used that in the past to do about what you're talking about. This allows me to search for stacks based on tags, just like almost every other thing in the AWS world.

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