2019-01-22 20:27:36 +00:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2018-10-11 14:17:57 -07:00
// 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
2019-01-22 20:27:36 +00:00
// snippet-start:[dynamodb.JavaScript.table.deleteTable]
2018-10-11 14:17:57 -07:00
// Load the AWS SDK for Node.js
var AWS = require ( "aws-sdk" ) ;
// Set the region
AWS . config . update ( { region : "REGION" } ) ;
2019-01-22 20:27:36 +00:00
// Create the DynamoDB service object
2018-10-11 14:17:57 -07:00
var ddb = new AWS . DynamoDB ( { apiVersion : "2012-08-10" } ) ;
var params = {
TableName : process . argv [ 2 ] ,
} ;
2019-01-22 20:27:36 +00:00
// Call DynamoDB to delete the specified table
2018-10-11 14:17:57 -07:00
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 ) ;
}
} ) ;
2019-01-22 20:27:36 +00:00
// snippet-end:[dynamodb.JavaScript.table.deleteTable]