从 CloudFormation 模板标记父堆栈

Lee*_*ton 5 version-control tagging templates amazon-web-services aws-cloudformation

有没有办法从模板本身在 CloudFormation 堆栈上创建标签?(父堆栈,不是嵌套堆栈)

我们有许多模板,它们会随着每个新版本的软件而更新。我们的软件版本被标记(在 git 中),并且一眼就能看到特定堆栈与哪个版本一起使用会很好。

模板的顶层结构指定了 6 个嵌套部分:

{
  "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
  }
}
Run Code Online (Sandbox Code Playgroud)

但是这些部分似乎都不允许标记堆栈本身(希望我在这里遗漏了一些东西)。

是的,我可以向元数据部分添加一个版本字符串,并且可以通过查看特定堆栈的模板来查看,但是在 AWS 中使用标签要容易得多。此外,它可以更轻松地控制谁可以更新/删除堆栈。

由于这个限制,目前我们没有太多使用堆栈标签。

小智 2

这看起来很有希望:

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

  create-stack
--stack-name <value>
...
[--tags <value>]
...
Run Code Online (Sandbox Code Playgroud)

我想我过去曾用它来做你所说的事情。这使我能够根据标签搜索堆栈,就像 AWS 世界中的几乎所有其他事物一样。

  • 谢谢,但我想要一个可以在模板本身中定义标签的解决方案。您是正确的,您可以在启动堆栈时(或创建之后)手动定义标签,不幸的是,这似乎是目前唯一的选择。希望他们很快就会添加该功能。 (3认同)