https://github.com/amancevice/terraform-aws-dynamodb-query-state-machine
AWS Step Function to execute DynamoDB queries with recursive pagination
https://github.com/amancevice/terraform-aws-dynamodb-query-state-machine
Last synced: 28 days ago
JSON representation
AWS Step Function to execute DynamoDB queries with recursive pagination
- Host: GitHub
- URL: https://github.com/amancevice/terraform-aws-dynamodb-query-state-machine
- Owner: amancevice
- License: mit
- Created: 2023-01-25T02:51:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-25T16:36:30.000Z (over 2 years ago)
- Last Synced: 2025-02-10T18:11:32.869Z (3 months ago)
- Language: HCL
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DynamoDB Query State Machine
[](https://registry.terraform.io/modules/amancevice/dynamodb-query-state-machine/aws)
[](https://github.com/amancevice/terraform-aws-dynamodb-query-state-machine/actions/workflows/validate.yml)AWS Step Function to execute DynamoDB queries with recursive pagination.
Use this state machine to execute DynamoDB queries and optionally send each page of results to a callback handler state machine.
## Example Input
Given the input:
```json
{
"Callback": "arn:aws:states:us-west-2:123456789012:stateMachine:my-callback",
"TableName": "MyTable",
"IndexName": "MyIndex",
"KeyConditionExpression": "#PKey=:PKey",
"ExpressionAttributeNames": { "#PKey": "PKey" },
"ExpressionAttributeValues": { ":PKey": "MyPartition" },
"Limit": 25
}
```The state machine will find successive pages of 25 items in the partition `MyPartition` and start a new execution of the `my-callback` state machine with each page of results as input.
If 100 items exist in the table with a `PKey` value of `MyPartition`, then the query state machine will invoke itself 3x (not including the initial invocation) and the `my-callback` state machine will be invoked 4x.
## Usage
```terraform
provider "aws" {
region = "us-west-2"
}module "dynamodb_query" {
source = "amancevice/dynamodb-query-state-machine/aws"
name = "my-dynamodb-query" # required
allowed_callbacks = ["my-callback-state-machine"] # optional
}
```## Advanced Usage
```terraform
provider "aws" {
region = "us-west-2"
}module "dynamodb_query" {
source = "amancevice/dynamodb-query-state-machine/aws"
name = "my-dynamodb-query"
allowed_callbacks = ["my-example-state-machine"]
type = "STANDARD" # "EXPRESS"logging_configuration = {
include_execution_data = false
level = "ALL"
log_destination = ""
}retries_dynamodb = [{
BackoffRate = 2
IntervalSeconds = 3
MaxAttempts = 4
ErrorEquals = [
"DynamoDB.InternalServerErrorException",
"DynamoDB.ItemCollectionSizeLimitExceededException",
"DynamoDB.LimitExceededException",
"DynamoDB.RequestLimitExceeded",
"DynamoDB.ThrottlingException",
]
}]retries_states = [{
BackoffRate = 2
IntervalSeconds = 3
MaxAttempts = 4
ErrorEquals = [
"States.ServiceUnavailable",
"States.ThrottlingException",
]
}]role = {
description = "My custom role description"
name = "my-custom-role-name"
path = "/my-custom-role-path/"
}tags = {
"git:repo" = "amancevice/terraform-aws-dynamodb-query-state-machine"
}tracing_configuration = {
enabled = true
}
}
```