Skip to content

feat(aws-node-step-functions): add a Step Functions example with a live test - #843

Merged
czubocha merged 2 commits into
v4from
branch/dreamy-lamport-709whe-sfn
Nov 25, 2026
Merged

czubocha merged 2 commits into
v4from
branch/dreamy-lamport-709whe-sfn

Conversation

@czubocha

Copy link
Copy Markdown
Contributor

Adds aws-node-step-functions: a Standard AWS Step Functions state machine deployed with the community plugin serverless-step-functions (pinned to 3.31.2), with a live test.

What it teaches

One lesson: define a state machine under stepFunctions in serverless.yml, deploy it with the Framework, and run it with the plugin's serverless invoke stepf command. The workflow is the same shape as aws-node-durable-function (a step, a 10-second wait, a result), so the two can be compared like with like:

  • ValidateOrder (Task, Lambda) → IsValid (Choice) → WaitTenSeconds (Wait) → ProcessOrder (Task, Lambda, with Retry)
  • the Choice's default branch goes to Rejected (Pass), for an order without an orderId
  • the state machine is named order-workflow-${sls:stage}; id: OrderWorkflow keeps the stack output OrderWorkflowArn the same on every stage

Node.js 24, arm64, ES modules, no runtime dependencies; the plugin is the only (development) dependency.

Left out on purpose: Express workflows, Catch and failure states, events that start an execution (HTTP, schedule, EventBridge), state machine logging and X-Ray, service integrations other than Lambda, callbacks (.waitForTaskToken), alarms and notifications. Each is a separate lesson; the README's Next steps link the plugin's README and the Amazon States Language reference for them.

Check

test/smoke.mjs runs what the README's Try it runs, serverless invoke stepf --name orderWorkflow, twice:

  • with a unique orderId: the execution must be SUCCEEDED with output status: "processed", the same orderId, and completedAt at least 9 s after acceptedAt (the Wait state);
  • with {}: the execution must be SUCCEEDED with output status: "rejected" (the Choice's default branch).

Test plan

us-east-1, Framework 4.47.0.

  • Live test: PASS aws-node-step-functions 4.47.0 189s (stage exoty53qj3g). Check line: execution …:order-workflow-exoty53qj3g:…: SUCCEEDED, order smoke-6itgxz5t processed 10.379 s after it was accepted; execution …: SUCCEEDED, order without orderId rejected.
  • Negative control (scratch copy expecting status: "shipped"): FAIL scratch-neg/sfn-neg 4.47.0 216s at the check step, expected output status "shipped"; got {"orderId":"smoke-hbrmq0v7","status":"processed",…}.
  • README followed by hand from a clean copy of the committed files (npm ci, serverless deploy, both invoke stepf commands, aws stepfunctions get-execution-history, serverless info --verbose, serverless remove); every output in the README comes from these runs.
  • Fresh-agent test: an agent given only the README deployed the example, ran both executions (SUCCEEDED, processed after the 10-second wait, and {"status":"rejected","orderId":null}), listed the same 16 history events ending in ExecutionSucceeded, removed the example and confirmed the stack was gone.
  • Nothing left after the runs: no stack, state machine, log group, IAM role or Lambda function from the example.
  • npm audit (dev dependencies included): 0 vulnerabilities.
  • npm test (323 pass), npm run validate, npm run check-docs, node scripts/check-examples.mjs aws-node-step-functions --package: clean.

Generated by Claude Code

@czubocha
czubocha merged commit e0c67f6 into v4 Nov 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant