Created
February 12, 2019 06:43
-
-
Save ox1111/796ac458d0c8f0c7a6317991b2c4aa04 to your computer and use it in GitHub Desktop.
dynamodb_createTable.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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