Step Functions <> Dynamodb integrations with dynamodb-toolbox features
A set of constructs to leverage dynamodb-toolbox features in a Step Functions <> Dynamodb direct integration.
Why ?
AWS direct integrations are great for shipping less custom code, thus less bugs
However, functionless is not always an option and you may already be relying on dynamodb-toolbox in some of your lambdas. In this case, implementing a Step Functions <> Dynamodb direct integration turns out to be painful because you would have to implement dynamodb-toolbox features yourself (e.g. generate created / modified / entity properties, or handle alias and maps).
How ?
This library aims at getting the best developer experience
import { StateMachine } from "aws-cdk-lib/aws-stepfunctions";
import { DynamodbToolboxQuery } from "sfn-dynamodb-toolbox-integrations";
// Define your query state
const queryTask = new DynamodbToolboxQuery(this, "QueryTask", {
entity: DynamodbToolboxEntityToQuery,
tableArn: "arn:aws:dynamodb:us-east-2:123456789012:table/myDynamoDBTable",
// Attributes to retrieve should be entity aliases
options: { attributes: ["id", "created"] },
});
// And use it in your step function
const stateMachine = new StateMachine(this, "QueryStateMachine", {
definition: queryTask,
});
NB: This library is in alpha for its current limitations, however it's already being used in production in some projects. The main limitation being:
We have released the Query construct while PutItem, UpdateItem and GetItem constructs are under active development.
Available DynamoDB-toolbox entity features
Entity definition
These entity properties are currently handled:
DDB-toolbox entity options | GetItem | UpdateItem | PutItem | Query |
---|---|---|---|---|
attributes | ||||
autoExecute | true (default) |
|||
autoParse | true (default) |
|||
created | ||||
createdAlias | ||||
modified | ||||
modifiedAlias | ||||
name | ||||
table | ||||
timestamps | ||||
typeAlias | ||||
typeHidden | false (default) |
Entity attributes
These entity attribute properties are currently handled:
DDB-toolbox attribute feature | GetItem | UpdateItem | PutItem | Query |
---|---|---|---|---|
alias | ||||
coerce | ||||
default | ||||
delimiter | ||||
dependsOn | ||||
format | ||||
hidden | false (default) |
|||
map | ||||
onUpdate | ||||
prefix | ||||
suffix | ||||
partitionKey | ||||
sortKey | ||||
required | ||||
save | true (default) |
|||
setType | ||||
transform | ||||
type | string , number , boolean
|