- How to author a state machine in the Step Functions visual editor
- Invoking Lambda functions from tasks
- Using a Choice state to branch on task results
- Inspecting execution inputs, outputs, and events for troubleshooting
- Open the Step Functions console and choose Create state machine.

- Choose a template. For this demo use the Blank template so you can author the workflow from scratch.

- Familiarize yourself with the visual editor:
- Canvas (center): Start → … → End
- Left panel: actions and integrations (Lambda, SNS, SQS, ECS, etc.)
- Right panel: properties for the selected state
- Receive an event (camera/object identifier)
- Invoke
detect_threatLambda to decide if the event is a threat - Branch: invoke
threat_foundif malicious, otherwisefalse_positive

- Add the first Task: invoke the
detect_threatLambda
- Drag an AWS Lambda Invoke task to the canvas.
- Configure:
- Name:
Detect Threat(or similar) - Integration: optimized Lambda integration
- Function:
detect_threat - Payload: use state input as the task
Payload(or filter usingInputPath/Parameters) - Leave “Wait for callback” disabled for this demo
- Set Next to the Choice state you’ll add next
- Optionally add Retry and Catch handlers if desired
- Name:


- Add a Choice state to branch on the
detect_threatresult
- Drag a Choice state from the Flow section and connect it after
Detect Threat. - Create rules that inspect
$.result.

- Rule 1:
$.resultequals"THREAT"→ route to Lambdathreat_found - Rule 2:
$.resultequals"NO_THREAT"→ route to Lambdafalse_positive - Optionally set a Default route for unexpected input

InputPath, Parameters, ResultPath, and OutputPath to select and shape the data passed between states for tighter control.
- Create the state machine
- Click Create. Step Functions will offer to create an IAM execution role with permissions required by the states (for example, permissions to invoke Lambda and optionally X-Ray).
- Inspect or refine the generated role if you need stricter least-privilege policies.
Step Functions can automatically create the execution role and attach the permissions required by the states you chose (for example, Lambda invocation and X‑Ray). Review and tighten the generated policy if your security posture requires least‑privilege access.

The console validates retry and catcher configurations. Remove or fix any unused catchers or invalid error handlers before creating the state machine to avoid runtime surprises.
- Start executions and inspect runs
- From the state machine details page choose Start execution and provide JSON input representing the event, for example:
- Start the execution. The visual execution trace will color states as they run and show which branch was taken based on the
detect_threatresult. - Click any state in the execution trace to view input/output JSON, timestamps, duration, and any SDK responses.

detect_threat is randomized here, so different runs will exercise both branches. You can review the list of executions and their statuses (Succeeded, Failed, Timed out, Aborted) from the State Machines list view.


- Authoring a state machine with the Step Functions visual editor
- Invoking Lambda functions from Task states
- Using Choice states to branch based on task outputs
- Inspecting inputs, outputs, and events to debug executions
- Integrate other services: SNS, SES, DynamoDB, SQS, ECS
- Add robust retry and Catch logic for production resiliency
- Use Map or Parallel states for data-parallel or concurrent workflows
- Tighten generated IAM roles for least-privilege access