AWS Step Functions to Amazon Aurora Serverless v2 with Amazon RDS Data API transactions

Client AWS CLI → AWS Step Functions Workflow → Amazon Aurora Serverless → AWS Secrets Manager Secret

An AWS Step Functions workflow runs a multi-statement SQL transaction on Amazon Aurora Serverless v2 through the Amazon RDS Data API and rolls it back on failure.

An AWS Step Functions state machine opens a transaction with the Amazon RDS Data API, runs three SQL statements (insert an order, decrement stock with a guard, insert an audit row) with the same transaction id, and commits.
A statement error, or zero updated rows, calls RollbackTransaction and ends the execution in a Fail state, so none of the statements stay visible in the Amazon Aurora Serverless v2 database. No AWS Lambda function is in the request path.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/sfn-aurora-data-api/typescript/cdk

Deploy

npm installnpm run buildnpx cdk bootstrapnpx cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

npx cdk destroy

Created by:

Nithin Chandran R

Nithin Chandran R

Technical Account Manager at AWS