-
Notifications
You must be signed in to change notification settings - Fork 128
Add initial documentation for Step Functions mocked service integrations (v4.4) #1747
Conversation
|
🎊 PR Preview has been successfully built and deployed to https://localstack-docs-preview-pr-1747.surge.sh 🎊 |
joe4dev
left a comment
There was a problem hiding this 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_CONFIGto 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: |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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/)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 \ |
There was a problem hiding this comment.
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?
joe4dev
left a comment
There was a problem hiding this 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`. |
There was a problem hiding this comment.
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. | |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 👏 🥇
quetzalliwrites
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
|
I've reviewed the doc preview and it looks good to merge: |
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.