The getDynamoDBTableDetails extension retrieves an item from an Amazon DynamoDB table from inside a Virtuoso journey.
This is useful when your test needs to fetch database values from DynamoDB and reuse the returned item in later journey steps.
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; -
secretKeyrequired, the AWS secret access key used to connect to DynamoDB. Store this as an environment variable where possible; -
tablenamerequired, the name of the DynamoDB table to query; -
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 getDynamoDBTableDetails 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 fetch an item from a DynamoDB table:
execute "getDynamoDBTableDetails" using "us-west-2" as region, "$awsAccessKey" as accessKey, "$awsSecretKey" as secretKey, "TableName" as tablename, '{"partitionKey":"PrimaryKeyValue","sortKey":"SortKeyValue"}' as primarykey1 returning $responseTo fetch an item using only a partition key:
execute "getDynamoDBTableDetails" using "us-west-2" as region, "$awsAccessKey" as accessKey, "$awsSecretKey" as secretKey, "TableName" as tablename, '{"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 "getDynamoDBTableDetails" using "$region" as region, "$accessKey" as accessKey, "$secretKey" as secretKey, "$tableName" as tablename, "$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 "getDynamoDBTableDetails" using "$region" as region, "$accessKey" as accessKey, "$secretKey" as secretKey, "$tableName" as tablename, "$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"}This extension requires the following resource:
The extension should be configured as:
- Run asynchronously: No
- Scope: Global
Limitation: This extension performs a DynamoDB get operation using the provided primary key. Make sure the AWS credentials have permission to read from the table, the table exists in the selected AWS region, and the primary key JSON matches the table key schema. If no matching record exists, the extension returns null.
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 getDynamoDBItem(awsRegion, awsAccessKey, awsSecretKey, tableName, primaryKey) {
// Configure the AWS SDK with your credentials and region
AWS.config.update({
region: awsRegion,
credentials: new AWS.Credentials({
accessKeyId: awsAccessKey,
secretAccessKey: awsSecretKey
})
});
// Create a DynamoDB document client
const dynamoDB = new AWS.DynamoDB.DocumentClient();
try {
// Construct the GetItem request parameters
const params = {
TableName: tableName,
Key: primaryKey
};
// Fetch the item from DynamoDB
const response = await dynamoDB.get(params).promise();
console.log("Item fetched successfully!");
return response.Item || null;
} catch (error) {
throw error;
}
}
// Example usage:
const awsRegion = region;
const awsAccessKey = accessKey;
const awsSecretKey = secretKey;
const tableName = tablename;
const primaryKey = JSON.parse(primarykey1);
console.log(primaryKey);
return getDynamoDBItem(awsRegion, awsAccessKey, awsSecretKey, tableName, primaryKey);
Comments
0 comments
Please sign in to leave a comment.