Aws-cdk: StateMachine - support for definition string or JSON

Created on 22 May 2020  路  2Comments  路  Source: aws/aws-cdk

When creating Step Functions StateMachine there is no possibility to provide already created definition string.

Also there is no way of creating IChainable from definition string of JSON which would also solve the issue.

That would be extremely useful for our use-case, when it is more convenient to define initial flow steps in JSON file and then edit them programmatically.

When using low-level CfnStateMachine there is no way of getting state machine ARN, so workaround is to construct it by hands, also we loose some helpers there.

Use Case

  1. We have JSON file template for creating EMR execution step functions taking care of: cluster creation, initialisation, error handling, and shutdown logic.
  2. Template is parsed and actual work steps are being added programmatically based on external configuration.
  3. Also some project parts define whole flow in JSON file, and use CDK to create supporting resources only.

Having possibility to convert IChainable to and from JSON would also help a lot for early state machine testing and debugging.

Proposed Solution

a) Add JSON input support to Chain similar to one we have in CustomState which does accept JSON as input, but works only for single state.

b) Add support for definitionString in StateMachine similar to one we have in CfnStateMachine

c) Add support for definitionJson in StateMachine similar to one we have in CustomState

Other


This is a :rocket: Feature Request

@aws-cdaws-stepfunctions efforlarge feature-request p1

Most helpful comment

Another motivation point is that AWS have nice support for working with JSON definition, so would be great to have possibility to import it nicely into CDK

https://aws.amazon.com/blogs/compute/aws-step-functions-support-in-visual-studio-code/

All 2 comments

@erik-telesoftas thanks for logging the issue! I think that's an interesting use case and one that would be useful. I like option a as getting a Chain back as you do in custom state allows you to manipulate and reuse a definition or partial definition of a state machine in addition to using the definition json directly.

for option b I'm more hesitant because we have introduced a few new concepts in authoring state machines within the CDK and it feels like we might be taking a step back into the L1. I think it's the least flexible of the group.

Another motivation point is that AWS have nice support for working with JSON definition, so would be great to have possibility to import it nicely into CDK

https://aws.amazon.com/blogs/compute/aws-step-functions-support-in-visual-studio-code/

Was this page helpful?
0 / 5 - 0 ratings