4
votes

I am new to AWS, so this might be a simple question.

When I create a DynamoDB table using AWS CloudFormation template, I do not see a way to provide a name for the table. So in the end it is named something like {stackName}-{resourceName}-{randomLetters}. However, if I create DynamoDB table manually, I have a possibility to provide a table name.

My template:

  "Resources" : {
    "mytable" : {
      "Type" : "AWS::DynamoDB::Table",
      "Properties" : {
        "KeySchema" : {
          "HashKeyElement": {
            "AttributeName" : {"Ref" : "HashKeyElementName"},
            "AttributeType" : {"Ref" : "HashKeyElementType"}
          }
        },
        "ProvisionedThroughput" : {
          "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"},
          "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"}
        }                              
      }
    }
    ...
  }

For instance, if I create a stack called "mystack", created DynamoDB table would have a name similar to "mystack-mytable-NUEXAXXOMBXX".

2
By "AWS template", you mean Amazon CloudFormation. :)Ryan Parman

2 Answers

20
votes

You can give your table a name by using the "Tablename" property. Here's the link to the docs.

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"                       
    }
  }
}
-1
votes

You aren't able to give your table a name. You'll need to capture this after it is created and use it inside your application