-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
ddb_deletetable.js
executable file
·30 lines (25 loc) · 1.05 KB
/
ddb_deletetable.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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// ABOUT THIS NODE.JS SAMPLE: This sample is part of the SDK for JavaScript Developer Guide topic at
// https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-examples-using-tables.html
// snippet-start:[dynamodb.JavaScript.table.deleteTable]
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });
// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({ apiVersion: "2012-08-10" });
var params = {
TableName: process.argv[2],
};
// Call DynamoDB to delete the specified table
ddb.deleteTable(params, function (err, data) {
if (err && err.code === "ResourceNotFoundException") {
console.log("Error: Table not found");
} else if (err && err.code === "ResourceInUseException") {
console.log("Error: Table in use");
} else {
console.log("Success", data);
}
});
// snippet-end:[dynamodb.JavaScript.table.deleteTable]