Skip to content

Instantly share code, notes, and snippets.

@alex-samborskiy
Created June 6, 2019 14:14
Show Gist options
  • Select an option

  • Save alex-samborskiy/b8856a9a5c95ab4153018e18dedd374e to your computer and use it in GitHub Desktop.

Select an option

Save alex-samborskiy/b8856a9a5c95ab4153018e18dedd374e to your computer and use it in GitHub Desktop.
[Create Seciondery Global Index to existing DDB table] #DynamoDB
const DynamoDB = require('aws-sdk/clients/dynamodb');
const dynamoDB = new DynamoDB();
dynamoDB.updateTable(
{
TableName: `development-publication-tasks`,
AttributeDefinitions: [
{ AttributeName: 'sort_key', AttributeType: 'S' },
{ AttributeName: 'attributeChanged', AttributeType: 'S' }
],
GlobalSecondaryIndexUpdates: [
{
Create: {
IndexName: 'attributeChanged-sort_key-index',
KeySchema: [
{ AttributeName: 'attributeChanged', KeyType: 'HASH' },
{ AttributeName: 'sort_key', KeyType: 'RANGE' }
],
Projection: {
ProjectionType: 'ALL'
},
ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1 }
}
}
]
},
function (err, data) {
console.log(err);
console.log(data);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment