Skip to content

Instantly share code, notes, and snippets.

@ox1111
Created February 12, 2019 06:43
Show Gist options
  • Save ox1111/796ac458d0c8f0c7a6317991b2c4aa04 to your computer and use it in GitHub Desktop.
Save ox1111/796ac458d0c8f0c7a6317991b2c4aa04 to your computer and use it in GitHub Desktop.
dynamodb_createTable.js
var aws = require('aws-sdk');
aws.config.update({region: 'us-west-2'});
// creat the dynamodb service object
//
var ddb = new aws.DynamoDB({apiVersion: '2019-02-12'});
var params = {
AttributeDefinitions: [
{
AttributeName: 'CUSTOMER_ID',
AttributeType: 'N'
},
{
AttributeName: 'CUSTOMER_NAME',
AttributeType: 'S'
}
],
KeySchema: [
{
AttributeName: 'CUSTOMER_ID',
KeyType: 'HASH'
},
{
AttributeName: 'CUSTOMER_NAME',
KeyType: 'RANGE'
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
},
TableName: 'CUSTOMER_LIST',
StreamSpecification: {
StreamEnabled: false
}
};
// Call DynamoDB to create the table
ddb.createTable(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Table Created", data);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment