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 to extract the ASL Definition 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
Options:
-V, --version output the version number
-f, --file-name <value> CloudFormation JSON File
-h, --help display help for command
Extract ASL
cdk-asl-definition-extractor -f </path/to/the/template.json>
The Output
[
{
"identifier": "<StackResourceName>",
"definition": "<ASL Definition>"
}
]
Wrap Up
Plenty more to come on this and I'll be working to extend/expand its capabilities.
Top comments (3)
Cool, can I see an example of how your step function looks in CDK? We actually do use the ASL to pass into CDK using
@matthewbonig/state-machine
and it looks something like this:Here are a few in my repos. They are simple but my production workflows are using the same setup with more complicated machines. I've abandoned using ASL in favor of using the CDK Constructs. I love it
Hope this helps
Awesome thanks, I will take a look!