繁体   English   中英

我们如何在 Cloudformation 模板中将相同的标签用于两个 AWS::DynamoDB::Table

[英]How we can use same Tags into two AWS::DynamoDB::Table with in Cloudformation Template

我正在尝试使用 Cloud Formation Template 创建 Amazon DynamoDB 表。 所以我的问题是我可以使用参考在多个表中使用相同的标签吗?

 "AWSTemplateFormatVersion": "2010-09-09",
      "Resources": {
        "Status": {
          "Type": "AWS::DynamoDB::Table",
          "Properties": {
            "AttributeDefinitions": [
              {
                "AttributeName": "SId",
                "AttributeType": "S"
              }
            ],
            "KeySchema": [
              {
                "AttributeName": "SId",
                "KeyType": "HASH"
              }
            ],
            "ProvisionedThroughput": {
              "ReadCapacityUnits": "1",
              "WriteCapacityUnits": "1"
            },
            "TableName": "Statuscf",
           
            "Tags": [
              {
                "Key": "Application",
                "Value": "BFMS"
              },
              {
                "Key": "Name",
                "Value": "EventSourcingDataStore"
              }
            ]
          }
        },
        "BMSHSData": {
          "Type": "AWS::DynamoDB::Table",
          "Properties": {
           
            
            "TableName": "Billing.FmsDatacf",
           
            "Tags": [{"Ref":"/Status/Tags"}]
          }
        }
      }

请建议我如何在另一个表中使用相同的标签。 我正在使用 Like this "Tags": [{"Ref":"/Status/Tags"}]。

使用普通 CloudFormation 执行此操作的唯一方法是复制和粘贴。 因此,您必须“手动”复制所有表的标签。 唯一的自动化解决方案是通过开发CloduFormation 宏自定义资源 另一种选择可能是通过使用嵌套堆栈

要解决这个问题,只需要在CF的Parameter Section中传递Tags Properties。 在此处输入图像描述

然后像这样在 DynamoDB 中使用这些标签

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM