rights reserved. Amazon Confidential and Trademark Jerome Van Der Linden (@jeromevdl) Automate Local Testing of CDK-defined Step Functions Solutions Architect Builder @ AWS
rights reserved. Amazon Confidential and Trademark Who am I ? Jérôme Van Der Linden Solutions Architect Builder @ AWS (Geneva, Switzerland) Former consultant, developer, tech lead, agile & devops coach, architect @ OCTO Technology Husband and Dad of 3 jeromevdl
rights reserved. Amazon Confidential and Trademark Objec8ves • Unit testing AWS Step Functions State Machines • Defined with CDK code • Locally without reaching the cloud • Automate as much as possible the process
rights reserved. Amazon Confidential and Trademark CDK Deploy Since I recorded this video, I discovered cdk-asl-extractor It permits to retrieve the ASL without deploying the stack. 😀🤩 Use cdk synth to get the CloudFormation template and use cdk-asl-extractor to get the ASL from the template.
rights reserved. Amazon Confidential and Trademark Mocked service integration MockConfigFile.json State Machine name Mocked states Mocked responses names Mocked responses definitions
rights reserved. Amazon Confidential and Trademark Step Functions Local Create the state machine locally: State machine definition (ASL / JSON) State Machine name (same as in the MockConfigFile.json)
rights reserved. Amazon Confidential and Trademark Unit Tests State Machine name (same as in the MockConfigFile.json) Test case name (same as in the MockConfigFile.json) Local endpoint
rights reserved. Amazon Confidential and Trademark Wrap-up 1. Retrieve the state machine ASL from the CDK code 2. Create Mocked Service integration config
rights reserved. Amazon Confidential and Trademark Wrap-up 1. Retrieve the state machine ASL from the CDK code 2. Create Mocked Service integration config 3. Start Step Functions local with this mocked configuration 4. Create a State Machine locally
rights reserved. Amazon Confidential and Trademark Wrap-up 1. Retrieve the state machine ASL from the CDK code 2. Create Mocked Service integration config 3. Start Step Functions local with this mocked configuration 4. Create a State Machine locally 5. Run your tests (using the SDK)
rights reserved. Amazon Confidential and Trademark Wrap-up 1. Retrieve the state machine ASL from the CDK code 2. Create Mocked Service integration config 3. Start Step Functions local with this mocked configuration 4. Create a State Machine locally 5. Run your tests (using the SDK)
rights reserved. Amazon Confidential and Trademark • Testing Step Functions State Machines Locally • https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.html • Using Mocked Service Integrations • https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.html • Mocking service integrations with AWS Step Functions Local • https://aws.amazon.com/blogs/compute/mocking-service-integrations-with-aws-step-functions-local/ • Code Sample GitHub • https://github.com/aws-samples/step-functions-direct-integrations/tree/main/direct-integration/infra