CDK ASL Definition Extractor

I’ve been working a good bit lately to push testing down when using Step Functions and building some patterns with AWS State Machines Locally. In that same spirit, I’m wanting to be able to create the State Machine in my local container and that comes from the ASL. However, when using CDK and the builder libraries you don’t have an ASL file to work from. So I built this program which I’m calling CDK ASL Definition Extractor which extracts the Definitions from a CDK synth’d CloudFormation file.

I’ve written a good bit about CDK so if you are looking for some intro this article is a good place to start. But if you’ve moved passed that and are looking to further build upon some more advanced patterns, I’ll have a follow-up article on how to use the Local Step Functions container in conjunction with this program.

CDK ASL Definition Extractor Usage

If you just want to jump straight to the README or the NPM package you can do that here:

This is a simple command line utility that takes the CDK Template output and parses through to extract out the AWS::StepFunctions::StateMachine resources and then outputs them to the STDOUT so that you can do something with that definition.

For usage

Preview Options

❯ cdk-asl-definition-extractor -h
Usage: cdk-asl-definition-extractor [options]

Extract AWS State Machine definitions from CDK generated ASL

  -V, --version            output the version number
  -f, --file-name   CloudFormation JSON File
  -h, --help               display help for command

Extract ASL

cdk-asl-definition-extractor  -f 

The Output

            "identifier": "",
            "definition": ""

Wrap Up

Plenty more to come on this and I’ll be working to extend/expand its capabilities.

Published by Benjamen Pyle

Benjamen is a genuine and resourceful technology creator with over 20 years of hands-on software development, team building and leadership experience. His passion is enabling technology teams to be their best by bridging modern technical design with outstanding business problem-solving. Recognized as an AWS Community leader in the areas of Event-Driven and Serverless Architecture, he brings multiple years of pragmatic experience designing and operating modern cloud-native and containerized solutions. When Benjamen doesn't have his head in the clouds, he's either playing golf with his wife and 2 boys or they are outside with their 12 paws.