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

Commit efe83c8

Browse files
committed
pr items
1 parent b21cbec commit efe83c8

File tree

2 files changed

+51
-43
lines changed

2 files changed

+51
-43
lines changed

content/en/references/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ Please consult the [migration guide]({{< ref "user-guide/aws/lambda#migrating-to
337337
| `SQS_DISABLE_CLOUDWATCH_METRICS` | `0` (default) | Disables the CloudWatch Metrics for SQS when set to `1` |
338338
| `SQS_CLOUDWATCH_METRICS_REPORT_INTERVAL` | `60` (default) | Configures the report interval (in seconds) for `Approximate*` metrics that are sent to CloudWatch periodically. Sending will be disabled if `SQS_DISABLE_CLOUDWATCH_METRICS=1` |
339339

340+
### Step Functions
341+
342+
| Variable | Example Values | Description |
343+
| - | - | - |
344+
| `SFN_MOCK_CONFIG` | `/tmp/MockConfigFile.json` | Specifies the file path to the mock configuration file that defines mock service integrations for Step Functions. |
345+
340346
## Security
341347

342348
{{< callout "warning" >}}

content/en/user-guide/aws/stepfunctions/index.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ LocalStack's Step Functions emulation supports the following AWS services:
137137

138138
Mocked service integrations allow you to test AWS Step Functions without calling LocalStack's emulated AWS services.
139139
Instead, Task states return predefined outputs from a mock configuration file.
140-
They key components are:
140+
The key components are:
141141

142142
- **Mocked service integrations**: Task states that return predefined responses instead of invoking local AWS services.
143143
- **Mocked responses**: Static payloads associated with mocked Task states.
@@ -148,66 +148,71 @@ During execution, each Task state defined in the mock file returns its correspon
148148
States not listed continue to invoke their real emulated services, allowing a mix of mocked and live interactions.
149149

150150
You can provide one or more mocked payloads per Task state.
151-
Supported patterns include `.sync`, `.sync2`, and `.waitForTaskToken`.
151+
The Supported patterns include `.sync`, `.sync2`, and `.waitForTaskToken`.
152152
Both success and failure scenarios can be simulated.
153153

154+
### Compatibility with AWS Step Functions Local
155+
156+
LocalStack can also serve as a drop-in replacement for [AWS Step Functions Local testing with mocked service integrations](https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-test-sm-exec.html).
157+
It supports test cases with mocked Task states and maintains compatibility with existing Step Functions Local configurations.
158+
This functionality is extended in LocalStack by providing access to the latest Step Functions features such as [JSONata and Variables](https://blog.localstack.cloud/aws-step-functions-made-easy/), as well as the ability to enable both mocked and emulated service interactions emulated by LocalStack.
159+
154160
{{< callout >}}
155161
LocalStack does not validate response formats.
156-
Ensure the payload structure matches what the real service expects.
162+
Ensure the payload structure in the mocked responses matches what the real service expects.
157163
{{< /callout >}}
158164

159165
### Identify a State Machine for Mocked Integrations
160166

161167
Mocked service integrations apply to specific state machine definitions.
162168
The first step is to select the state machine where mocked responses will be used.
163169

164-
In this example, the `LambdaSQSIntegration` state machine will be used with the following definition:
170+
In this example, the state machine with the name `LambdaSQSIntegration` state machine will be used with the following definition:
165171

166172
```json
167173
{
168-
"Comment":"This state machine is called: LambdaSQSIntegration",
169-
"QueryLanguage":"JSONata",
170-
"StartAt":"LambdaState",
171-
"States":{
172-
"LambdaState":{
173-
"Type":"Task",
174-
"Resource":"arn:aws:states:::lambda:invoke",
175-
"Arguments":{
176-
"FunctionName":"GreetingsFunction",
177-
"Payload":{
178-
"fullname":"{% $states.input.name & ' ' & $states.input.surname %}"
174+
"Comment": "This state machine is called: LambdaSQSIntegration",
175+
"QueryLanguage": "JSONata",
176+
"StartAt": "LambdaState",
177+
"States": {
178+
"LambdaState": {
179+
"Type": "Task",
180+
"Resource": "arn:aws:states:::lambda:invoke",
181+
"Arguments": {
182+
"FunctionName": "GreetingsFunction",
183+
"Payload": {
184+
"fullname": "{% $states.input.name & ' ' & $states.input.surname %}"
179185
}
180186
},
181-
"Retry":[
187+
"Retry": [
182188
{
183-
"ErrorEquals":[ "States.ALL" ],
184-
"IntervalSeconds":2,
185-
"MaxAttempts":4,
186-
"BackoffRate":2
189+
"ErrorEquals": [ "States.ALL" ],
190+
"IntervalSeconds": 2,
191+
"MaxAttempts": 4,
192+
"BackoffRate": 2
187193
}
188194
],
189-
"Assign":{
190-
"greeting":"{% $states.result.Payload.greeting %}"
195+
"Assign": {
196+
"greeting": "{% $states.result.Payload.greeting %}"
191197
},
192-
"Next":"SQSState"
198+
"Next": "SQSState"
193199
},
194-
"SQSState":{
195-
"Type":"Task",
196-
"Resource":"arn:aws:states:::sqs:sendMessage",
197-
"Arguments":{
198-
"QueueUrl":"http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/localstack-queue",
199-
"MessageBody":"{% $greeting %}"
200+
"SQSState": {
201+
"Type": "Task",
202+
"Resource": "arn:aws:states:::sqs:sendMessage",
203+
"Arguments": {
204+
"QueueUrl": "http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/localstack-queue",
205+
"MessageBody": "{% $greeting %}"
200206
},
201-
"End":true
207+
"End": true
202208
}
203209
}
204210
}
205211
```
206212

207213
### Define Mock Integrations in a Configuration File
208214

209-
Mock integrations are defined in a JSON file that follows the `RawMockConfig` schema.
210-
The file contains two top-level sections:
215+
Mock integrations are defined in a JSON file with two top-level section:
211216

212217
- **StateMachines** – Maps each state machine to its test cases, specifying which states use which mocked responses.
213218
- **MockedResponses** – Defines reusable mock payloads identified by `ResponseID`, which test cases refer to.
@@ -273,7 +278,7 @@ In the example above:
273278
- `Throw`: Simulates failure with `Error` and `Cause`.
274279

275280
{{< callout >}}
276-
Each entry must have **either** `Return` or `Throw`—not both.
281+
Each entry must have **either** `Return` or `Throw`, but cannot have both.
277282
{{< /callout >}}
278283

279284
Here is a full example of the `MockedResponses` section:
@@ -383,11 +388,10 @@ localstack start --volume /path/to/MockConfigFile.json:/tmp/MockConfigFile.json
383388
services:
384389
localstack:
385390
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
386-
image: localstack/localstack-pro
391+
image: localstack/localstack
387392
ports:
388393
- "127.0.0.1:4566:4566" # LocalStack Gateway
389394
- "127.0.0.1:4510-4559:4510-4559" # external services port range
390-
- "127.0.0.1:443:443" # LocalStack HTTPS Gateway (Pro)
391395
environment:
392396
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
393397
- DEBUG=${DEBUG:-0}
@@ -399,8 +403,6 @@ services:
399403
{{< /tab >}}
400404
{{< /tabpane >}}
401405

402-
This tells LocalStack to use the specified file for mocked service integrations during Step Functions execution.
403-
404406
### Run Test Cases with Mocked Integrations
405407

406408
Create the state machine to match the name defined in the mock configuration file.
@@ -413,15 +415,15 @@ $ awslocal stepfunctions create-state-machine \
413415
--role-arn "arn:aws:iam::000000000000:role/service-role/testrole"
414416
{{< /command >}}
415417

416-
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.
418+
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) API.
417419

418420
To execute a test case, append the test case name to the state machine ARN using `#`.
419421
This tells LocalStack to apply the mocked responses from the configuration file.
420422
For example, run the `BaseCase` test case:
421423

422424
{{< command >}}
423425
$ awslocal stepfunctions start-execution \
424-
--state-machine arn:aws:states:ca-central-1:000000000000:stateMachine:LambdaSQSIntegration#BaseCase \
426+
--state-machine arn:aws:states:us-east-1:000000000000:stateMachine:LambdaSQSIntegration#BaseCase \
425427
--input '{"name": "John", "surname": "smith"}' \
426428
--name "MockExecutionBaseCase"
427429
{{< /command >}}
@@ -433,15 +435,15 @@ You can inspect the execution using the [`DescribeExecution`](https://docs.aws.a
433435

434436
{{< command >}}
435437
$ awslocal stepfunctions describe-execution \
436-
--execution-arn "arn:aws:states:ca-central-1:000000000000:execution:LambdaSQSIntegration:MockExecutionBaseCase"
438+
--execution-arn "arn:aws:states:us-east-1:000000000000:execution:LambdaSQSIntegration:MockExecutionBaseCase"
437439
{{< /command >}}
438440

439441
The sample output shows the execution details, including the state machine ARN, execution ARN, status, start and stop dates, input, and output:
440442

441443
```json
442444
{
443-
"executionArn": "arn:aws:states:ca-central-1:000000000000:execution:LambdaSQSIntegration:MockExecutionBaseCase",
444-
"stateMachineArn": "arn:aws:states:ca-central-1:000000000000:stateMachine:LambdaSQSIntegration",
445+
"executionArn": "arn:aws:states:us-east-1:000000000000:execution:LambdaSQSIntegration:MockExecutionBaseCase",
446+
"stateMachineArn": "arn:aws:states:us-east-1:000000000000:stateMachine:LambdaSQSIntegration",
445447
"name": "MockExecutionBaseCase",
446448
"status": "SUCCEEDED",
447449
"startDate": "...",
@@ -461,7 +463,7 @@ You can also use the [`GetExecutionHistory`](https://docs.aws.amazon.com/step-fu
461463

462464
{{< command >}}
463465
$ awslocal stepfunctions get-execution-history \
464-
--execution-arn "arn:aws:states:ca-central-1:000000000000:execution:LambdaSQSIntegration:MockExecutionBaseCase"
466+
--execution-arn "arn:aws:states:us-east-1:000000000000:execution:LambdaSQSIntegration:MockExecutionBaseCase"
465467
{{< /command >}}
466468

467469
This will return the full execution history, including entries that indicate how the mocked responses were applied to the Lambda and SQS states.

0 commit comments

Comments
 (0)