【问题标题】:Share tags between different resource types in cloudformation template在 cloudformation 模板中不同资源类型之间共享标签
【发布时间】:2020-01-04 00:13:53
【问题描述】:

我正在尝试编写一个 SAM 模板来拥有一个触发 Lambda 函数的 IoT 规则。出于计费原因,我正在使用的帐户需要使用一长串标识符标记所有资源。这些总是相同的,为每个资源重复复制它们似乎是一种耻辱。 SAM 允许在一种资源类型之间共享全局变量(因此每个函数都可以共享标签),但我没有看到在资源类型之间应用全局标签的好方法。

我考虑过使用参数并尝试引用它,但没有支持的参数类型允许标签的键/值结构。 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

我很想做这样的事情:

Parameters:
  UniversalTags:
    Type: KeyValueObject
    Default:
      - 
        Key: "Name"
        Value: "my name"
      - 
        Key: "Manager"
        Value: "my manager"
      -
        Key: "Market"
        Value: "my market"
       -
        Key: "Engagement Office"
        Value: "location"
      -
        Key: "Email"
        Value: "email@test.com"

Resources:
  IoTProcessingFunction:
    Type: AWS::Serverless::Function 
    Properties:
      Tags: !Ref UniversalTags

  IoTRule:
    Type: AWS::IoT::TopicRule
    Properties:
      Tags: !Ref UniversalTags

有谁知道实现这个的方法吗?

【问题讨论】:

    标签: yaml amazon-cloudformation aws-sam


    【解决方案1】:

    这是 CloudFormation 做得不好的地方。查看AWS CDK。它允许您编写生成 CloudFormation 的代码。您的 CloudFormation 仍将是重复的,但您无需查看或维护它,并且您只能在 CDK 中描述标签一次

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-24
      • 2021-12-19
      • 1970-01-01
      • 2017-09-28
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多