在AWS CloudFormation模板中提供DynamoDB表名称

Mak*_*kin 4 amazon-web-services amazon-dynamodb

我是AWS的新手,所以这可能是一个简单的问题.

当我使用AWS CloudFormation模板创建DynamoDB表时,我没有看到为表提供名称的方法.所以最后它被命名为{stackName}-{resourceName}-{randomLetters}.但是,如果我手动创建DynamoDB表,我有可能提供表名.

我的模板:

  "Resources" : {
    "mytable" : {
      "Type" : "AWS::DynamoDB::Table",
      "Properties" : {
        "KeySchema" : {
          "HashKeyElement": {
            "AttributeName" : {"Ref" : "HashKeyElementName"},
            "AttributeType" : {"Ref" : "HashKeyElementType"}
          }
        },
        "ProvisionedThroughput" : {
          "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"},
          "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"}
        }                              
      }
    }
    ...
  }
Run Code Online (Sandbox Code Playgroud)

例如,如果我创建一个名为"mystack"的堆栈,则创建的DynamoDB表将具有类似于"mystack-mytable-NUEXAXXOMBXX"的名称.

Han*_*nny 20

您可以使用"Tablename"属性为表指定名称.这是文档的链接.

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html

"Resources" : {
  "mytable" : {
    "Type" : "AWS::DynamoDB::Table",
    "Properties" : {
      "KeySchema" : {
        "HashKeyElement": {
          "AttributeName" : {"Ref" : "HashKeyElementName"},
          "AttributeType" : {"Ref" : "HashKeyElementType"}
        }
      },
      "ProvisionedThroughput" : {
        "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"},
        "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"}
      },
      "TableName": "MyDynamoDBTableName"                       
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 你可以命名,**如果你从不尝试进行修改**.这意味着没有架构或吞吐量的变化. (4认同)
  • @jhilden 在文档中查找“更新需要:替换”。如果您修复了名称,这些是您无法做到的。您可以更改吞吐量,但不能更改架构或索引。 (2认同)