Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Conversation

@MEPalma
Copy link
Contributor

@MEPalma MEPalma commented Apr 30, 2025

This PR adds initial documentation for the AWS Step Functions mocked service integrations feature, introduced in LocalStack v4.4. The new docs cover the basic structure and usage of mock configuration files, including test cases and mocked responses. Future updates will expand on this foundation with LocalStack usage examples, detailed behavioral notes, and advanced mock scenarios.

@MEPalma MEPalma added the documentation Improvements or additions to documentation label Apr 30, 2025
@MEPalma MEPalma self-assigned this Apr 30, 2025
@github-actions
Copy link

github-actions bot commented Apr 30, 2025

🎊 PR Preview has been successfully built and deployed to https://localstack-docs-preview-pr-1747.surge.sh 🎊

Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a comprehensive example for the Step Functions mocking feature, kinda like a full announcement blog post 👏

My main suggestions are:

  • clarifying the connection to the AWS mocking feature or motivating (in the PR description) why not. Can/should we link to AWS documentation instead of re-documenting what the AWS documentation already provides for advanced features?
  • add the new configuration SFN_MOCK_CONFIG to the config docs

Otherwise, I added several minor suggestions.

I tested the example and can confirm it works (after adjusting the ARNs to using us-east-1).

Sidenote: the preview link https://localstack-docs-preview-pr-1747.surge.sh/user-guide/aws/stepfunctions/ didn't render for me (maybe outdated), but I can confirm rendering works locally.


Mocked service integrations allow you to test AWS Step Functions without calling LocalStack's emulated AWS services.
Instead, Task states return predefined outputs from a mock configuration file.
They key components are:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: The


## Mocked Service Integrations

Mocked service integrations allow you to test AWS Step Functions without calling LocalStack's emulated AWS services.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be helpful to link the AWS documentation from StepFunctions Local here? https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.html
Knowing that we are providing a drop-in replacement seems pretty relevant here, given that it was one of the primary reasons why we built this feature.

(or their announcement blog: https://aws.amazon.com/blogs/compute/mocking-service-integrations-with-aws-step-functions-local/)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely; I added a Compatibility with AWS Step Functions Local paragraph

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done highlighting the strengths of LocalStack beyond what SFN local can provide 👏 🥇

- **Mock configuration file**: JSON file that defines test cases, mocked states, and their response payloads.

During execution, each Task state defined in the mock file returns its corresponding mocked response.
States not listed continue to invoke their real emulated services, allowing a mix of mocked and live interactions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: great clarification ✨

States not listed continue to invoke their real emulated services, allowing a mix of mocked and live interactions.

You can provide one or more mocked payloads per Task state.
Supported patterns include `.sync`, `.sync2`, and `.waitForTaskToken`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The supported ...


{{< callout >}}
LocalStack does not validate response formats.
Ensure the payload structure matches what the real service expects.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we clarify?

payload structure in the mocked responses matches

services:
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
image: localstack/localstack-pro
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we intentionally using the pro image for showcasing a community feature?
Using the community compose could simplify things a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the pro image as it is used for the LDM, but I agree this is best if presented with the community version


### Provide the Mock Configuration to LocalStack

Set the `SFN_MOCK_CONFIG` configuration variable to the path of the mock configuration file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document SFN_MOCK_CONFIG in the configuration section as well?

{{< /tab >}}
{{< /tabpane >}}

This tells LocalStack to use the specified file for mocked service integrations during Step Functions execution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this sentence after the code pane add extra value?
suggestion: better specify any preview (what it does) and required information before the code section.

--role-arn "arn:aws:iam::000000000000:role/service-role/testrole"
{{< /command >}}

After the state machine is created and named correctly, test cases from the mock configuration file can be run using the [`StartExecution`](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html) or [StartSyncExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartSyncExecution.html) APIs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: intentional ` and non-` ?


{{< command >}}
$ awslocal stepfunctions start-execution \
--state-machine arn:aws:states:ca-central-1:000000000000:stateMachine:LambdaSQSIntegration#BaseCase \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to adopt the default LocalStack region us-east-1 everywhere?

@MEPalma MEPalma requested a review from joe4dev May 6, 2025 11:14
Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for polishing ✨ @MEPalma

Waiting for 👀 from docs maintainers 🚀


You can provide one or more mocked payloads per Task state.
Supported patterns include `.sync`, `.sync2`, and `.waitForTaskToken`.
The Supported patterns include `.sync`, `.sync2`, and `.waitForTaskToken`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: The supported


| Variable | Example Values | Description |
| - | - | - |
| `SFN_MOCK_CONFIG` | `/tmp/MockConfigFile.json` | Specifies the file path to the mock configuration file that defines mock service integrations for Step Functions. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 idea (for future): Would a standardized default value within the container simplify the setup, because then users only need to provide the volume mount?
We might want to standardize this following the LocalStack file system layout: https://docs.localstack.cloud/references/filesystem/


## Mocked Service Integrations

Mocked service integrations allow you to test AWS Step Functions without calling LocalStack's emulated AWS services.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done highlighting the strengths of LocalStack beyond what SFN local can provide 👏 🥇

Copy link
Collaborator

@quetzalliwrites quetzalliwrites left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@quetzalliwrites
Copy link
Collaborator

I've reviewed the doc preview and it looks good to merge:
https://localstack-docs-preview-pr-1747.surge.sh/user-guide/aws/stepfunctions/

@quetzalliwrites quetzalliwrites merged commit a7b2b06 into main May 8, 2025
3 of 5 checks passed
@quetzalliwrites quetzalliwrites deleted the MEP-SFN-initial_sfn_mock branch May 8, 2025 01:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants