Skip to content

Instantly share code, notes, and snippets.

@arfon
Created January 21, 2012 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arfon/1650887 to your computer and use it in GitHub Desktop.
Save arfon/1650887 to your computer and use it in GitHub Desktop.
AWS DynamoDB table creation (composite primary_key)
require 'aws-sdk'
AWS_ACCESS_KEY = 'your_aws_access_key'
AWS_SECRET_KEY = 'your_aws_secret_key'
dynamo_db = AWS::DynamoDB.new(:access_key_id => AWS_ACCESS_KEY, :secret_access_key => AWS_SECRET_KEY)
# create a table (50 read and 50 write capacity units)
# create composite index using hash_key (:user_id) and range_key (:created_at)
table = dynamo_db.tables.create("tweets", 50, 50,
:hash_key => { :user_id => :number },
:range_key => { :created_at => :number })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment