Step Machine definition lacks proper formatting
See original GitHub issueThe synthesized Cloudformation from of a step-machine cdk definition lacks formatting.
State machine ( AWS::StepFunctions::StateMachine
) JSON Strings (DefinitionString
) is generated in a single line, new lines characters (\n) and spaces could be added to provide proper visualization in the AWS Console since this is still used to check step-machine execution steps. Been able to visualize the step machine code properly helps the Developer User Experience. Currently this is an undesired outcome.
There is a workaround to fix this and consists in Editing State machine definition and formatting it from the AWS Console.
Reproduction Steps
Create CDK Typescript App with following code:
import * as cdk from '@aws-cdk/core';
import * as sfn from '@aws-cdk/aws-stepfunctions';
export class CdkWorkshopStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const pass = new sfn.Pass(this, 'Pass');
const step_definition = pass;
new sfn.StateMachine(this, 'StateMachine', {
definition: step_definition,
timeout: cdk.Duration.seconds(30)
});
}
}
Comparison
Generated cloudformation resource property for the AWS::StepFunctions::StateMachine
type:
DefinitionString: '{"StartAt":"Pass","States":{"Pass":{"Type":"Pass","End":true}},"TimeoutSeconds":30}'
Expected output:
DefinitionString":"{\n \"StartAt\": \"Pass\",\n \"States\": {\n \"Pass\": {\n \"Type\": \"Pass\",\n \"End\": true\n }\n },\n \"TimeoutSeconds\": 30\n}"
Environment
- **CLI Version :1.38.0 (build d5fa31f)
- Framework Version:
- **OS :Ubuntu 20.04
- **Language :en
Other
Side comparison of AWS Console. Default:
Expected:
*With lager state machine definition the cumbersome is to visualize it in the editor
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:15 (7 by maintainers)
Top GitHub Comments
@kristianpaul As an alternative to the console, you can visualize the graph (and format the code) in VS Code using the AWS Toolkit.
See:
Closing this issue as no changes will be (or were) made to the CDK for this