Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provide DynamoDB table name in AWS CloudFormation template

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".

like image 863
Maksim Sorokin Avatar asked Dec 01 '22 20:12

Maksim Sorokin


1 Answers

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"                       
    }
  }
}
like image 91
Hanny Avatar answered Dec 06 '22 20:12

Hanny