Let’s create a DynamoDB Table with default settings by giving it just a Table Name & Partition Key

| Term | Required? | Used For | Think Of It As |
|---|---|---|---|
| Partition Key | ✅ Yes | Determines data location | "Where to store the item" |
| Sort Key | ❌ Optional | Groups & sorts items | "How to order related items" |
The Partition Key is the primary key used to determine where the data is physically stored in DynamoDB.
“This value decides where in the system the data goes.”
The Sort Key is optional and is used to store multiple related items under the same Partition Key.
“This value decides how to order or group related items under the same Partition Key.”

While the table gets created. Let’s create a State Machine in Step Functions : ( i am calling it DynamoDBStateMachine)

{
"Comment": "Transaction Processor State Function",
"StartAt": "Process Transaction",
"States": {
"Process Transaction": {
"Type": "Pass",
"Next": "StoreHistory"
},
"StoreHistory": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "TransactionHistory",
"Item": {
"TransactionId": {
"S.$": "$$.Execution.Id"
}
}
},
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 1,
"MaxAttempts": 3
}
],
"ResultPath": "$.DynamoDB",
"End": true
}
}
}