Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions sfn-dynamodb-cdk/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# Create an AWS Step Functions workflow to integrate with Amazon DynamoDB

The CDK application deploys a Step Functions workflow, that takes in a payload and puts the item in DynamoBb. Additionally, this workflow also shows how to read an item directly from the DynamoDB table. The CDK application contains the minimum IAM resources required to run the application.
You can find the SAM template for the same pattern [here](https://serverlessland.com/patterns/sfn-dynamodb)
You can find the SAM template for the same pattern [here](https://serverlessland.com/patterns/sfn-dynamodb)

Learn more about this pattern at: https://serverlessland.com/patterns/sfn-dynamodb-cdk.

Expand Down Expand Up @@ -57,7 +56,7 @@ command.

Run the following AWS CLI command to send a 'start-execution` command to start the Step Functions workflow. Note, you must edit the {StateMachineArn} placeholder with the ARN of the deployed Step Functions workflow. This is provided in the stack outputs.
```bash
aws stepfunctions start-execution --name "test" --state-machine-arn "{StateMachineArn}" --input "{\"id\": \"12345\" }"
aws stepfunctions start-execution --name "test" --state-machine-arn "{StateMachineArn}" --input "{\"id\": \"12345\" }"
```

### output:
Expand All @@ -72,7 +71,7 @@ aws stepfunctions start-execution --name "test" --state-machine-arn "{StateMach
Note the `executionArn` from the above output and run the below cli command to get the status of the execution

```bash
aws stepfunctions describe-execution --execution-arn "{executionArn}"
aws stepfunctions describe-execution --execution-arn "{executionArn}"
```

### Get execution status output:
Expand All @@ -85,7 +84,7 @@ aws stepfunctions describe-execution --execution-arn "{executionArn}"
"status": "SUCCEEDED",
"startDate": 1620674586.347,
"stopDate": 1620674586.553,
"input": "{\"id\": \"123456\" }",
"input": "{\"id\": \"123456\" }",
"inputDetails": {
"included": true
},
Expand All @@ -99,7 +98,7 @@ Once the `status` is `SUCCEEDED`, you can verify what was stored in DynamoDB tab
Additionally, you can also verify if the item is stored in DynamoDB by running the below get item cli command on the table.

```bash
aws dynamodb get-item --table-name my-table --key "{\"id\": {\"S\": \"12345\"} }"
aws dynamodb get-item --table-name {tableName} --key "{\"id\": {\"S\": \"12345\"} }"
```

### DynamoDB Get Item Output:
Expand All @@ -118,7 +117,7 @@ Additionally, you can also verify if the item is stored in DynamoDB by running t
```

## Cleanup

1. Delete the stack
```bash
cdk destroy
Expand Down
2 changes: 1 addition & 1 deletion sfn-dynamodb-cdk/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
aws-cdk-lib==2.13.0
aws-cdk-lib==2.260.0
constructs>=10.0.0,<11.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
definition = send_to_ddb.next(read_from_ddb)
state_machine = sfn.StateMachine(
self, "SfnToDDBWorkflowStateMachine",
definition=definition,
definition_body=sfn.DefinitionBody.from_chainable(definition),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[WARNING] aws-cdk-lib.aws_stepfunctions.StateMachineProps#definition is deprecated.
  use definitionBody: DefinitionBody.fromChainable()
  This API will be removed in the next major release.

timeout=Duration.minutes(5)
)

Expand Down