sfn-dynamodb-toolbox-integrations
TypeScript icon, indicating that this package has built-in type declarations

0.2.1-alpha • Public • Published

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 🐞 in your CDK applications. They enable communication with Dynamodb inside a state machine, rather than using a lambda as a service integration task and use your favorite tool such as dynamodb-toolbox to communicate with Dynamodb for simple requests like GetItem, PutItem, UpdateItem or Query.

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 💻 while benefiting from dynamodb-toolbox features in Step Functions <> Dynamodb direct integrations. To query entity items inside a state machine, define your task with the Query construct at build time, and pass the partition key value at run time, just like you would do in a lambda with dynamodb-toolbox.

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: ⚠️ dynamodb-entities must be flat (i.e. no object or array properties).

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 💻 💻 💻 ⚠️ see below
autoExecute 💻 💻 💻 true (default)
autoParse 💻 💻 💻 true (default)
created 💻 💻 💻
createdAlias 💻 💻 💻
modified 💻 💻 💻
modifiedAlias 💻 💻 💻
name 💻 💻 💻
table 💻 💻 💻
timestamps 💻 💻 💻
typeAlias 💻 💻 💻
typeHidden 💻 💻 💻 false (default)

💻: under development

Entity attributes

These entity attribute properties are currently handled:

DDB-toolbox attribute feature GetItem UpdateItem PutItem Query
alias 💻 💻 💻
coerce 💻 💻 💻 (default)
default 💻 💻 💻
delimiter 💻 💻 💻
dependsOn 💻 💻 💻
format 💻 💻 💻
hidden 💻 💻 💻 false (default)
map 💻 💻 💻
onUpdate 💻 💻 💻
prefix 💻 💻 💻
suffix 💻 💻 💻
partitionKey 💻 💻 💻
sortKey 💻 💻 💻
required 💻 💻 💻
save 💻 💻 💻 true (default)
setType 💻 💻 💻
transform 💻 💻 💻
type 💻 💻 💻 ⚠️ string, number, boolean

💻: under development

Readme

Keywords

none

Package Sidebar

Install

npm i sfn-dynamodb-toolbox-integrations

Weekly Downloads

0

Version

0.2.1-alpha

License

none

Unpacked Size

142 kB

Total Files

38

Last publish

Collaborators

  • pmilliotte