Download AWS CloudFormation User Guide

Transcript
AWS CloudFormation User Guide
AWS::DynamoDB::Table
DynamoDB Table with Local and Secondary Indexes
The following sample creates an DynamoDB table with Album, Artist, and Sales as attributes. The
primary key includes the Album attribute as the hash key and Artist attribute as the range key. The
table also includes a global and a secondary index. For querying the number of sales for a given artist,
the global secondary index uses the Sales attribute as the hash key and the Artist attribute as the
range key. For querying the sales of an album, the local secondary index uses the same hash key as the
table but uses the Sales attribute as the range key.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Resources" : {
"myDynamoDBTable" : {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"AttributeDefinitions" : [
{
"AttributeName" : "Album",
"AttributeType" : "S"
},
{
"AttributeName" : "Artist",
"AttributeType" : "S"
},
{
"AttributeName" : "Sales",
"AttributeType" : "N"
}
],
"KeySchema" : [
{
"AttributeName" : "Album",
"KeyType" : "HASH"
},
{
"AttributeName" : "Artist",
"KeyType" : "RANGE"
}
],
"ProvisionedThroughput" : {
"ReadCapacityUnits" : "5",
"WriteCapacityUnits" : "5"
},
"TableName" : "myTableName",
"GlobalSecondaryIndexes" : [{
"IndexName" : "myGSI",
"KeySchema" : [
{
"AttributeName" : "Sales",
"KeyType" : "HASH"
},
{
"AttributeName" : "Artist",
"KeyType" : "RANGE"
}
],
"Projection" : {
API Version 2010-05-15
345