forked from aws-samples/aws-dynamodb-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable_streams.js
26 lines (21 loc) · 1.05 KB
/
enable_streams.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// The StreamViewType can be any of the following values 'NEW_IMAGE'|'OLD_IMAGE'|'NEW_AND_OLD_IMAGES'|'KEYS_ONLY',
// but if you want to use Global Tables, it must be set to NEW_AND_OLD_IMAGES.
const {DynamoDBClient, UpdateTableCommand } = require('@aws-sdk/client-dynamodb');
const REGION = "us-west-2";
const TableName = "Music";
const dbclient = new DynamoDBClient({ region: REGION });
async function enableStreams() {
const params = {
TableName: TableName,
StreamSpecification: {
StreamEnabled: true,
StreamViewType: "NEW_AND_OLD_IMAGES",
},
};
return await dbclient.send( new UpdateTableCommand(params));
// await waitForTableExists({ maxWaitTime: 20, maxDelay: 5, minDelay: 1 }, { TableName: TableName } );
// this code is commented out as there is something wrong with the waiters in v3. Once that is fixed, this code will be updated.
}
enableStreams()
.then((data) => console.log(data))
.catch((error) => console.log("An error occurred while enabling streams:" + ' ' + error.message ));