Using node.js i try to delete and create dynamoDB table again. I need to delete all records from table and put new, so i think is good solution to just delete and recreate whole table. I try with this code
dynamo.deleteTable({
TableName: tableName
}, function(err, data){
if (err) {
console.log(err);
}
else {
dynamo.createTable({
TableName: tableName,
KeySchema: [{
AttributeName: "id",
KeyType: "HASH"
}],
AttributeDefinitions: [{
AttributeName: "id",
AttributeType: "S"
}],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
}, function(err){
if (err) {
console.log(err);
}
else {
// putNewData(data, callback);
}
})
}
});
And i get error ResourceInUseException: Table already exists:
You can use the SDK's tableNotExists
waiter to ensure a table has been fully deleted before calling createTable
.