question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Step Machine definition lacks proper formatting

See original GitHub issue

The 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:

image

Expected:

image

*With lager state machine definition the cumbersome is to visualize it in the editor

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
wong-acommented, Jun 18, 2020
1reaction
peterwoodworthcommented, Apr 15, 2021

Closing this issue as no changes will be (or were) made to the CDK for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Amazon States Language - AWS Step Functions
The Amazon States Language is a JSON-based, structured language used to define your state machine, a collection of states, that can do work...
Read more >
Amazon States Language
This document describes a JSON-based language used to describe state machines declaratively. The state machines thus defined may be executed by software.
Read more >
AWS Step Functions — A User's Guide - Serverless Guru
A task performs work by using an activity or an AWS Lambda function, or passing parameters to the API actions of other services....
Read more >
The STEP File Format – Simply Explained - All3DP
STEP files, properly known as ISO 10303, are a popular file format for 3D models. The letters in the format's name stand for...
Read more >
AWS Step Function workflow is showing failed status when ...
The named WorkOnCaseFunction is not producing correct output which should be something like below structure. { Case: '001', Status: 0, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found