Created
June 6, 2019 14:14
-
-
Save alex-samborskiy/b8856a9a5c95ab4153018e18dedd374e to your computer and use it in GitHub Desktop.
[Create Seciondery Global Index to existing DDB table] #DynamoDB
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
| 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