The deleteItemInDynamoDB extension deletes an item from an Amazon DynamoDB table from inside a Virtuoso journey.
This is useful when your test needs to remove a database record from DynamoDB by using the record's primary key.
Parameters:
-
regionrequired, the AWS region where the DynamoDB table is located, for exampleus-west-2; -
accessKeyrequired, the AWS access key ID used to connect to DynamoDB. Store this as an environment variable where possible; -
secreteKeyrequired, the AWS secret access key used to connect to DynamoDB. Store this as an environment variable where possible; -
tablename1required, the name of the DynamoDB table where the item should be deleted; -
primaryKey1required, the DynamoDB primary key as a valid JSON string. This should include the partition key and, where required, the sort key.
Note: The primaryKey1 value must be valid JSON because the extension parses it using JSON.parse(primaryKey1). The JSON key names must match the DynamoDB table key attribute names exactly.
NLP usage
Use the extension in a journey by calling Delete Item In Dynamo DB with the execute command. Pass each value to the matching extension input using as inputName.
Note: Script inputs are passed as text in Virtuoso. Because of this, pass the primaryKey1 value as a JSON string, for example {"partitionKey":"PrimaryKeyValue","sortKey":"SortKeyValue"}.
To delete an item from a DynamoDB table:
execute "Delete Item In Dynamo DB" using "us-west-2" as region, "$awsAccessKey" as accessKey, "$awsSecretKey" as secreteKey, "TableName" as tablename1, '{"partitionKey":"PrimaryKeyValue","sortKey":"SortKeyValue"}' as primaryKey1 returning $responseTo delete an item using only a partition key:
execute "Delete Item In Dynamo DB" using "us-west-2" as region, "$awsAccessKey" as accessKey, "$awsSecretKey" as secreteKey, "TableName" as tablename1, '{"id":"PrimaryKeyValue"}' as primaryKey1 returning $responseYou can also use Virtuoso variables to make the same step reusable across different AWS regions, tables, or primary keys:
execute "Delete Item In Dynamo DB" using "$region" as region, "$accessKey" as accessKey, "$secretKey" as secreteKey, "$tableName" as tablename1, "$primaryKey" as primaryKey1 returning $responseExample setup using variables before calling the extension:
store value "us-west-2" in $region
store value "TableName" in $tableName
store value '{"partitionKey":"PrimaryKeyValue","sortKey":"SortKeyValue"}' in $primaryKey
execute "Delete Item In Dynamo DB" using "$region" as region, "$accessKey" as accessKey, "$secretKey" as secreteKey, "$tableName" as tablename1, "$primaryKey" as primaryKey1 returning $responseFor example, if your DynamoDB table uses partitionKey and sortKey as key attributes, the JSON should use the same names:
{"partitionKey":"PrimaryKeyValue","sortKey":"SortKeyValue"}When the delete request is successful, the extension returns the HTTP status code from the DynamoDB response, for example 200.
This extension requires the following resource:
The extension should be configured as:
- Run asynchronously: No
- Scope: Global
Limitation: This extension performs a DynamoDB delete operation using the provided primary key. Make sure the AWS credentials have permission to delete items from the table, the table exists in the selected AWS region, and the primary key JSON matches the table key schema.
Add the extension to your Virtuoso instance
Select the domain that matches your Virtuoso account.
View source
Last updated: 22/05/2026
Resources:
async function deleteDynamoDBItem(region, accessKey, secretKey, tableName, primaryKey) {
// Configure the AWS SDK with your credentials and region
AWS.config.update({
region: region,
credentials: new AWS.Credentials({
accessKeyId: accessKey,
secretAccessKey: secretKey
})
});
// Create a DynamoDB document client
const dynamoDB = new AWS.DynamoDB.DocumentClient();
try {
// Construct the DeleteItem request parameters
const params = {
TableName: tableName,
Key: primaryKey
};
// Delete the item from DynamoDB
const response = await dynamoDB.delete(params).promise();
const statusCode = response.$response.httpResponse.statusCode;
console.log("Item deleted successfully");
return statusCode;
} catch (error) {
throw error;
}
}
// Example usage:
const awsRegion = region;
const awsAccessKey = accessKey;
const awsSecretKey = secreteKey;
const tableName = tablename1;
const primaryKey = JSON.parse(primaryKey1);
// update this to the primary key value for which you wish to delete the item in DynamoDB
return deleteDynamoDBItem(awsRegion, awsAccessKey, awsSecretKey, tableName, primaryKey);
Comments
0 comments
Please sign in to leave a comment.