Skip to content

fix(aws-stepfunctions): apply timeout to FileDefinitionBody and StringDefinitionBody#37602

Open
Sagargupta16 wants to merge 1 commit intoaws:mainfrom
Sagargupta16:fix/state-machine-timeout-asl-json
Open

fix(aws-stepfunctions): apply timeout to FileDefinitionBody and StringDefinitionBody#37602
Sagargupta16 wants to merge 1 commit intoaws:mainfrom
Sagargupta16:fix/state-machine-timeout-asl-json

Conversation

@Sagargupta16
Copy link
Copy Markdown

Issue # (if applicable)

Closes #37150.

Reason for this change

The timeout property on StateMachine only applies when the definition body is a ChainDefinitionBody. When users provide an ASL JSON file via FileDefinitionBody or an inline JSON string via StringDefinitionBody, the timeout is silently ignored. This is unexpected and undocumented.

Description of changes

Modified FileDefinitionBody.bind() and StringDefinitionBody.bind() to inject TimeoutSeconds into the ASL definition JSON when sfnProps.timeout is specified.

For FileDefinitionBody: when a timeout is set, the file is read, parsed as JSON, TimeoutSeconds is added, and the result is returned as a definitionString (bypassing the S3 asset upload, since the definition needs modification). Without a timeout, behavior is unchanged (S3 asset upload).

For StringDefinitionBody: when a timeout is set, the JSON string is parsed, TimeoutSeconds is added, and the modified JSON is returned. Without a timeout, behavior is unchanged.

Describe any new or updated permissions being added

No permission changes.

Description of how you validated changes

Added three unit tests:

  • timeout is applied to StringDefinitionBody - verifies TimeoutSeconds is injected into inline JSON definitions
  • timeout is applied to FileDefinitionBody - verifies TimeoutSeconds is injected when definition comes from an ASL JSON file
  • StringDefinitionBody without timeout does not inject TimeoutSeconds - verifies no mutation when timeout is not specified

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…gDefinitionBody

The timeout property was only applied when using ChainDefinitionBody.
FileDefinitionBody and StringDefinitionBody silently ignored it, causing
unexpected behavior for users providing .asl.json or string definitions.

Now both definition body types parse the ASL JSON and inject
TimeoutSeconds when the timeout prop is specified. FileDefinitionBody
falls back to definitionString (instead of S3 upload) when timeout is
set so the injected value is included.

Fixes aws#37150
@github-actions github-actions bot added bug This issue is a bug. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cdk.aws_stepfunctions.StateMachine: timeout does not apply to .asl.json definition

1 participant