SQS — Batch Processing
A Lambda function that handles SQS messages by batch processing them and storing the processed results into a DynamoDB table. Partial batch failure reporting is enabled so that individual record failures do not cause the entire batch to be retried.
Architecture
The template sets up:
- Amazon SQS queue: Holds the incoming messages to be processed.
- AWS Lambda function: Processes messages in batches with partial failure reporting.
- Amazon DynamoDB table: Stores the processed items.

Code
- Function code:
templates/sqs - Unit tests:
tests/sqs - Infra stack:
infra/stacks/sqs.py
Deployment
Deploy the stack using:
mise run deploy sqs
Data models
SqsMessage
Parsed from the SQS message body.
| Field | Type | Description |
|---|---|---|
id |
string | Unique identifier for the message (1-50 chars) |
content |
string | The main content of the message (1-1000 chars) |
ProcessedItem
Written to the DynamoDB table.
| Field | Type | Description |
|---|---|---|
id |
string | Unique identifier for the item (partition key, 1-50 chars) |
content |
string | The processed content (1-1000 chars) |
status |
string | Processing status (1-50 chars) |
Environment variables
| Variable | Description | Required | Default |
|---|---|---|---|
TABLE_NAME |
Destination DynamoDB table name | Yes | - |
SERVICE_NAME |
Powertools service name | No | sqs-processor |
METRICS_NAMESPACE |
Powertools metrics namespace | No | SqsProcessor |
LOG_LEVEL |
Log level for the Lambda Logger | No | INFO |