-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathUpdateIndexProvisionedCapacity.js
34 lines (30 loc) · 1.26 KB
/
UpdateIndexProvisionedCapacity.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
27
28
29
30
31
32
33
34
// A simple example to update the provisioned capacity of a global secondary index (GSI) on an existing table DynamoDB table.
// Note: this specific example does not alter a GSI's auto-scaling settings or Contributor Insights settings. That is a different script.
const { DynamoDBClient, UpdateTableCommand } = require('@aws-sdk/client-dynamodb'); // ES Modules import
const REGION = "us-west-2";
const TableName = "Music";
const IndexName = "SongTitle-Artist-index";
async function updateIndex() {
const client = new DynamoDBClient({ region: REGION });
try {
return await client.send(
new UpdateTableCommand({
TableName: TableName,
GlobalSecondaryIndexUpdates: [ {
Update: {
IndexName: IndexName,
ProvisionedThroughput: {
ReadCapacityUnits: 25,
WriteCapacityUnits: 25,
},
}
}],
},)
);
} catch (err) {
console.error(err);
}
}
updateIndex()
.then((data) => console.log(data.TableDescription))
.catch((error) => console.log("An error occurred while updating the index capacity:" + ' ' + error.message ));