-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathDeleteIndex.js
29 lines (25 loc) · 923 Bytes
/
DeleteIndex.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
// A simple example to delete a global secondary index (GSI) on an existing table DynamoDB table.
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 deleteIndex() {
const client = new DynamoDBClient({ region: REGION });
try {
return await client.send(
new UpdateTableCommand({
TableName: TableName,
GlobalSecondaryIndexUpdates: [ {
Delete: {
IndexName: IndexName,
}
}],
},)
);
} catch (err) {
console.error(err);
}
}
deleteIndex()
.then((data) => console.log(data))
.catch((error) => console.log("An error occurred while creating the index:" + ' ' + error.message ));