Skip to content

Instantly share code, notes, and snippets.

@ankona
Created April 25, 2016 20:38
Show Gist options
  • Save ankona/8eb09a35d187e8cbc455799a8dd20c2e to your computer and use it in GitHub Desktop.
Save ankona/8eb09a35d187e8cbc455799a8dd20c2e to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
},
"Parameters": {
"EnvironmentParameter": {
"Type": "String",
"Default": "dev",
"AllowedValues": ["dev", "test", "stage", "lt", "prod"],
"Description": "Supply an environment from the choices: dev, test, stage, lt, or prod. The default is dev."
}
},
"Resources": {
"SearchLogTable": {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"AttributeDefinitions" : [ { "AttributeName": "search_id", "AttributeType": "S" },
{ "AttributeName": "user_id", "AttributeType": "S" },
{ "AttributeName": "timestamp", "AttributeType": "N" } ],
"KeySchema" : [ { "AttributeName": "search_id", "KeyType": "HASH" } ],
"ProvisionedThroughput" : {
"ReadCapacityUnits" : "3",
"WriteCapacityUnits" : "3"
},
"GlobalSecondaryIndexes": [{
"IndexName" : "user_id-timestamp-index",
"KeySchema" : [ { "AttributeName": "user_id", "KeyType": "HASH" },
{ "AttributeName": "timestamp", "KeyType": "RANGE" } ],
"Projection" : { "ProjectionType": "ALL" },
"ProvisionedThroughput" : { "ReadCapacityUnits" : "1", "WriteCapacityUnits" : "3" }
}],
"TableName": { "Fn::Join": ["", ["search_log_",
{ "Ref": "EnvironmentParameter" }]] }
}
},
"JobTrackerTable": {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"AttributeDefinitions" : [ { "AttributeName": "tracker_id", "AttributeType": "S" },
{ "AttributeName": "user_id", "AttributeType": "S" },
{ "AttributeName": "status", "AttributeType": "S" },
{ "AttributeName": "timestamp", "AttributeType": "N" },
{ "AttributeName": "client_id", "AttributeType": "S" },
{ "AttributeName": "job_id", "AttributeType": "S" }],
"KeySchema" : [ { "AttributeName": "tracker_id", "KeyType": "HASH" } ],
"ProvisionedThroughput" : {
"ReadCapacityUnits" : "3",
"WriteCapacityUnits" : "3"
},
"GlobalSecondaryIndexes": [
{ "IndexName" : "user_id-status-index",
"KeySchema" : [ { "AttributeName": "user_id", "KeyType": "HASH" },
{ "AttributeName": "status", "KeyType": "RANGE" } ],
"Projection" : { "ProjectionType": "ALL" },
"ProvisionedThroughput" : { "ReadCapacityUnits" : "2", "WriteCapacityUnits" : "1" }
},{
"IndexName" : "user_id-timestamp-index",
"KeySchema" : [ { "AttributeName": "user_id", "KeyType": "HASH" },
{ "AttributeName": "timestamp", "KeyType": "RANGE" } ],
"Projection" : { "ProjectionType": "ALL" },
"ProvisionedThroughput" : { "ReadCapacityUnits" : "2", "WriteCapacityUnits" : "1" }
}
],
"TableName": { "Fn::Join": ["", ["interest_tracker_",
{ "Ref": "EnvironmentParameter" }]] }
}
}
}
}
@ankona
Copy link
Author

ankona commented Apr 25, 2016

aws --profile <insert_profile_name> cloudformation create-stack --stack-name cmtest-params-stage --template-body file:///path/to/dynamo-cf-sample.json --parameters ParameterKey=EnvironmentParameter,ParameterValue=stage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment