Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 329
Lee Netherton Avatar asked Oct 30 '22 13:10

Lee Netherton


1 Answers

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.

like image 50
Bryan Kroger krogebry Avatar answered Nov 04 '22 10:11

Bryan Kroger krogebry