The following script will truncate a DynamoDB table:
const AWS = require("aws-sdk");
AWS.config.region = "us-east-1";
const dynamoDb = new AWS.DynamoDB();
async function truncate(tableName) {
const rows = await dynamoDb.scan({
TableName: tableName,
AttributesToGet: ['id'],
}).promise();
console.log(`Deleting ${rows.Items.length} records`);
rows.Items.forEach(async function(element, i) {
await dynamoDb.deleteItem({
TableName: tableName,
Key: element,
}).promise();
});
}
await truncate("events");
no it won’t, it will delete up to 1mb of data from the table (the amount returned by scan)