Perform DynamoDB CRUD operations with Step Functions
You can integrate Step Functions with DynamoDB to perform CRUD operations on a DynamoDB table. This page lists the supported
DynamoDB APIs and provides an example Task
state to retrieve an item from DynamoDB.
To learn about integrating with AWS services in Step Functions, see Integrating services and Passing parameters to a service API in Step Functions.
Key features of optimized DynamoDB integration
-
There is no optimization for the Request Response integration pattern.
-
The Wait for a Callback with Task Token integration pattern is not supported.
-
Only
GetItem
,PutItem
,UpdateItem
, andDeleteItem
API actions are available through optimized integration. Other API actions, such asCreateTable
are available using the DynamoDB AWS SDK integration.
The following is a Task
state that retrieves a message from DynamoDB.
"Read Next Message from DynamoDB": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "TransferDataRecords-DDBTable-3I41R5L5EAGT",
"Key": {
"MessageId": {"S.$": "$.List[0]"}
}
},
"ResultPath": "$.DynamoDB",
"Next": "Send Message to SQS"
},
To see this state in a working example, see the Transfer data records with Lambda, DynamoDB, and Amazon SQS sample project.
Note
There is a quota for the maximum input or result data size for a task in Step Functions. This restricts you to 256 KB of data as a UTF-8 encoded string when you send to, or receive data from, another service. See Quotas related to state machine executions.
Supported DynamoDB APIs
Parameters in Step Functions are expressed in PascalCase
Even if the native service API is in camelCase, for example the API action startSyncExecution
, you specify parameters in PascalCase, such as: StateMachineArn
.
IAM policies for calling DynamoDB
The following example templates show how AWS Step Functions generates IAM policies based on the resources in your state machine definition. For more information, see How Step Functions generates IAM policies for integrated services and Discover service integration patterns in Step Functions.
Static resources
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem"
],
"Resource": [
"arn:aws:dynamodb:[[region]]
:[[accountId]]
:table/[[tableName]]
"
]
}
]
}
Dynamic resources
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem"
],
"Resource": "*"
}
]
}
For more information about the IAM policies for all DynamoDB API actions, see IAM policies with DynamoDB in the Amazon DynamoDB Developer Guide. Additionally, for information about the IAM policies for PartiQL for DynamoDB, see IAM policies with PartiQL for DynamoDB in the Amazon DynamoDB Developer Guide.