Get DynamoDB table details
The getDynamoDBTableDetails extension retrieves a matching 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, validations, or API-driven test flows.
Parameters:
-
regionrequired, the AWS region string 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 DynamoDB table name string to query; -
primarykey1required, the DynamoDB primary key as a valid JSON string. This should include the partition key and, where required by the table schema, the sort key.
Note: The primarykey1 value must be valid JSON because the extension parses it using JSON.parse(primarykey1). The JSON key names and value types must match the DynamoDB table key schema exactly.
How to apply this to your journey
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 primarykey1 as a JSON string, for example {"partitionKey":"PrimaryKeyValue","sortKey":"SortKeyValue"}. Keep AWS credentials in variables rather than writing them directly in steps.
To fetch an item from a DynamoDB table using a partition key and sort key:
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, credentials, 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 $responseExample output when a matching item is found:
{
"partitionKey": "PrimaryKeyValue",
"sortKey": "SortKeyValue",
"status": "Active"
}If no matching item exists, the extension returns null.
This extension requires the following resource:
The extension should be configured as:
- Run asynchronously: No
- Scope: Global
Limitation: This extension depends on the external AWS SDK browser resource, valid AWS credentials, network access to DynamoDB, and a primary key JSON value that matches the selected table schema exactly. It performs a single DynamoDB get operation only; it does not scan, query secondary indexes, paginate results, retry throttled requests, or create missing records. AWS permission errors, expired or restricted credentials, blocked CDN loading, corporate proxy restrictions, browser/CORS restrictions, incorrect region or table names, malformed JSON, schema drift, rate limits, or DynamoDB service errors can cause the step to fail or return no item. The source code uses async, await, and promise(), but the extension is configured here as Run asynchronously: No to preserve the existing extension configuration and encoded add-extension payload. Validate this behavior in the target Virtuoso environment before using it for critical journeys; if the runtime does not resolve the returned Promise as expected, configure and implement the extension as an asynchronous script with explicit completion handling. Avoid placing secrets directly in journey text because credentials may be visible in step inputs, logs, or shared article examples.
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.