Skip to content

generateFromAwsResponse

function generateFromAwsResponse(params):
| SvgOutput
| HtmlOutput
| MermaidOutput;

Defined in: src/index.ts:277

Generate a diagram from an AWS SDK DescribeStateMachine response

This is a convenience function for integrating with the AWS SDK. It extracts the ASL definition from the response and generates a diagram.

GenerateFromAwsParams

Configuration object

| SvgOutput | HtmlOutput | MermaidOutput

SVG output if format is ‘svg’, Mermaid output if format is ‘mermaid’

If response.definition is missing

If the definition contains invalid JSON (also an instanceof SyntaxError and AslValidationError)

If the ASL definition structure is invalid

import { SFNClient, DescribeStateMachineCommand } from '@aws-sdk/client-sfn';
import { generateFromAwsResponse } from 'sfn-diagram';
const client = new SFNClient({ region: 'us-east-1' });
const response = await client.send(
new DescribeStateMachineCommand({
stateMachineArn: 'arn:aws:states:...'
})
);
const { svg } = generateFromAwsResponse({
response,
theme: 'light',
layout: 'TB'
});