【问题标题】:Generate cloud formation template from DynamoDB table从 DynamoDB 表生成云形成模板
【发布时间】:2017-03-24 01:30:36
【问题描述】:

我有一个 DynamoDB 表,需要复制到不同的环境。管理表格的最佳方式是使用 CloudFormation 模板,以便脚本可以基于模板创建表格。鉴于表已经存在,我想知道是否可以为现有表生成 e 模板,有什么想法吗?在 google 上找不到太多...

模板看起来像这样:

"Resources": {
    "CustomerTable": {
      "Type" : "AWS::DynamoDB::Table",
      "Properties" : {
        "KeySchema": [
          {
            "AttributeName": "customerId",
            "KeyType": "HASH"
          }
        ],
        "AttributeDefinitions": [
          {
            "AttributeName": "customerId",
            "AttributeType": "N"
          }
        ],
        "ProvisionedThroughput" : {
          "ReadCapacityUnits" : { "Ref": "CustomerReadCapacity" },
          "WriteCapacityUnits" : { "Ref": "CustomerWriteCapacity" }
        },
        "TableName" : "customer"
      }
    }
}

【问题讨论】:

    标签: amazon-web-services


    【解决方案1】:

    您可以使用 CloudFormer 从 AWS 账户中的现有资源生成 CloudFormation 模板。

    但是,生成的模板不会以任何方式链接到您现有的资源。 CloudFormer 将生成一个模板,该模板是您现有资源的副本。使用生成的模板将创建一个包含新资源的新 CloudFormation 堆栈。

    无法获取现有资源并将它们包含在 CloudFormation 堆栈中。如果您希望您的资源由 CloudFormation 管理,那么它们首先需要由 CloudFormation 创建。

    【讨论】:

    • 太棒了,让我试一试!
    • cloudFormer 使用起来很简单,但会让您跳过几个环节(创建虚拟机、选择要导出的资源等)。一个更简单的解决方案(使用一些手动复制粘贴)是使用 aws CLI (docs.aws.amazon.com/cli/latest/reference/dynamodb/…) 的 describe-table 获取表的布局。然后你可以保留你需要的字段(AttributeDefinitions 等等)并在它们周围放置一个 Cloudformation 骨架
    猜你喜欢
    • 2020-04-14
    • 2019-08-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-22
    • 2021-01-31
    • 2021-08-24
    • 2016-10-27
    • 2018-10-23
    相关资源
    最近更新 更多