AWS Certified CloudOps Engineer Associate SOA-C03 [2026]

AWS Step Functions: Create and Test a Lambda-Based State Machine

Learn how to provision Lambda functions, configure IAM permissions, import an AWS Step Functions state machine definition, and test Choice-based execution paths.

AWS Certified CloudOps Engineer Associate SOA-C03 [2026]AWS Certified CloudOps Engineer Associate SOA-C03 [2026]Updated Sep 1, 2026
Study options
WatchComing later
ListenComing later
ReadAvailable
ReviewComing later

Study guide

Technical reference and lesson notes

Purpose of This Lesson

This hands-on lesson demonstrates how to create an AWS Step Functions state machine that orchestrates several AWS Lambda functions. The workflow performs initial processing, uses document-type information to select a processing path, and then finalizes the operation.

The lab uses AWS CloudShell, AWS CLI commands, IAM, Lambda, and a JSON state machine definition. It also demonstrates how execution input affects a Choice state and how the Step Functions console visualizes the resulting workflow.

Key Concepts

  • AWS Step Functions state machine: A workflow definition that coordinates multiple states and Lambda functions.
  • Lambda tasks: Individual Lambda functions perform the processing stages in the workflow.
  • Choice state: Routes execution to different branches based on data in the execution input.
  • Execution input: JSON supplied when starting an execution. In this lab, the workflow examines the document type.
  • IAM Lambda execution role: The role supplied when creating the Lambda functions. The lab attaches AWSLambdaBasicExecutionRole.
  • Amazon States Language JSON: The JSON definition describes states, transitions, resources, and branching behavior.
  • CloudShell: Used to upload the deployment archive, extract the individual function packages, and run AWS CLI commands.
  • Execution visualization: The Step Functions console displays the workflow and shows the path taken during an execution.

Technical Implementation: Building and Testing the Workflow

1. Prepare the Lambda deployment packages

The lab materials include a step-functions directory containing items such as:

  • step-functions.md with the instructions
  • lambda.md containing the Lambda code
  • A ZIP archive containing the function packages
  • A JSON file containing the state machine definition

Upload the Lambda ZIP archive to AWS CloudShell and extract it. The extracted contents should provide separate ZIP files for the individual Lambda functions used by the workflow.

2. Create the Lambda execution role

Before creating the functions, create an IAM role for the Lambda service:

  1. Open IAM and create a role for an AWS service.
  2. Select Lambda as the use case.
  3. Attach the AWSLambdaBasicExecutionRole policy.
  4. Create the role using the name specified by the lab instructions.
  5. Copy the role ARN, because it is required by the Lambda creation commands and potentially by other configuration steps.

The role enables the Lambda functions to use the basic execution permissions required by the lab. The exact role ARN is account- and region-specific, so it must be replaced with the ARN from the current environment.

3. Create the Lambda functions

Use the AWS CLI commands supplied in the lab from CloudShell. Each command uses the Lambda create-function operation and provides values for:

  • Function name
  • Runtime
  • IAM role ARN
  • Handler, specified as the Lambda handler
  • Function code ZIP file

Replace the placeholder role ARN in every command before running them. Execute the commands for all five functions. The function packages already contain the code, so separate code editing should not normally be necessary.

After creation, inspect the functions in the Lambda console and verify that the deployed code corresponds to the supplied source. For example, the initial processing function simulates extracting information from a document and produces the document-type value used later by the workflow.

4. Update the state machine definition

Open the supplied Step Functions JSON definition. The definition contains the workflow states and Lambda resource references, but the Lambda ARNs may contain placeholder, region, or account values.

Update every Lambda resource ARN with the actual ARN of the corresponding function in the current account and Region. The relevant functions include the initial processing function, financial-document processing, HR-document processing, generic-document processing, and finalization.

When editing JSON:

  • Paste each ARN inside the quotation marks for the resource value.
  • Ensure the function name matches the function created in Lambda.
  • Check that the account number and Region are correct.
  • Save the updated definition before importing it.

The Step Functions console can create the service role needed by the state machine. In this lab, the console flow allows the required Lambda and X-Ray permissions to be created or configured as part of state machine creation.

5. Create the state machine

In the Step Functions console:

  1. Open Step Functions and choose Get started.
  2. Select the option to create a state machine and confirm the creation flow.
  3. Choose to define the workflow using code.
  4. Replace the starter definition in the code editor with the edited JSON.
  5. Review the visual representation shown beside the code.
  6. Correct any definition errors and confirm that the state ordering and transitions are correct.
  7. Finish creating the state machine and allow the console to configure the required permissions.

The visual editor is useful for validating how the JSON translates into states and transitions. It also provides a quick way to spot malformed definitions or unexpected ordering.

6. Start executions with different inputs

Start an execution from the state machine console and provide JSON input containing the document type expected by the Lambda logic. For example, the lab tests a financial document and an HR document using inputs that set the document type to the respective value.

The financial-document execution should follow a path similar to:

Initial processing → Choose document path → Process financial → Finalize

An HR execution should follow the HR processing branch instead. The generic branch can be tested by supplying the corresponding generic document type.

The decisive input is the document type returned or used by the initial processing logic. The Choice state evaluates that information and routes the execution to the matching Lambda task.

Exam- or Assessment-Relevant Takeaways

  • Recognize Step Functions as the orchestration layer when a workflow must coordinate multiple Lambda functions and include branching logic.
  • A Choice state is appropriate when the next step depends on values in the state input.
  • Lambda functions are individual processing units; Step Functions defines their order, transitions, and branching.
  • Lambda creation requires an execution role. In this lab, the role uses AWSLambdaBasicExecutionRole.
  • Resource ARNs in a state machine definition must refer to the actual Lambda functions in the current account and Region.
  • Execution input is not incidental: it drives the branch selected by the workflow.
  • The Step Functions visual editor and execution history are useful for validating both the definition and the runtime path.
  • When troubleshooting a failed workflow, check the Lambda ARNs, IAM role ARN, JSON syntax, handler and package alignment, and the execution input format.
  • The lab demonstrates a practical distinction between defining workflow logic in Amazon States Language and implementing individual processing actions in Lambda.

Tool / Feature Decision Guide

RequirementAppropriate tool or featureReason
Upload and unpack the supplied function archiveAWS CloudShellProvides a browser-based shell for file upload, extraction, and AWS CLI commands.
Run application processing codeAWS LambdaEach processing stage is packaged and deployed as an individual function.
Coordinate multiple functionsAWS Step FunctionsDefines the workflow, transitions, branching, and execution visualization.
Route execution based on document informationStep Functions Choice stateSelects a branch based on data in the workflow input.
Grant basic Lambda execution permissionsIAM role with AWSLambdaBasicExecutionRoleSupplies the execution role used by the Lambda functions in the lab.
Inspect the path taken by a runStep Functions execution viewShows which states executed and which branch was selected.
Reuse the workflow for another document categoryNew execution inputThe same state machine can be tested with a different document type rather than requiring a new workflow definition.

Common Traps / Misconceptions

  • Leaving placeholder ARNs in the JSON: The state machine cannot invoke the intended functions if the resource ARNs still contain the wrong account number, Region, or function name.
  • Confusing the Lambda role with the state machine role: Lambda functions need their execution role, while Step Functions also requires permissions to invoke the configured Lambda resources. The console can assist with the state machine permissions during creation.
  • Assuming the workflow chooses a branch automatically: The branch depends on the document-type information supplied or produced during execution.
  • Editing Lambda code unnecessarily: The lab ZIP archive already contains the function code. First verify the deployed code before modifying it.
  • Pasting an ARN outside the JSON string: Resource ARNs must remain valid JSON string values.
  • Testing only one path: A successful financial execution does not prove that the HR or generic branches are configured correctly. Run executions with different document types.
  • Treating the visual editor as the workflow definition itself: The JSON code is the state machine definition; the visual view represents that definition and helps validate it.
  • Forgetting cleanup: The lab indicates that unused Step Functions and Lambda resources can be deleted after testing.

Real-World Engineer / Analyst Notes

  • Keep the state machine definition and Lambda deployment artifacts under version control so that ARN substitutions and workflow changes are traceable.
  • Use clearly separated function names for each processing responsibility. This makes resource mapping and execution troubleshooting easier.
  • Validate the resource ARN mapping systematically. A state machine with correct logic can still fail if one task points to the wrong function.
  • Test both expected and alternate document types. Branch coverage is especially important in workflows because an untested branch can hide configuration or permission errors.
  • Use the execution visualization to distinguish a routing problem from a function problem. If the wrong branch is selected, inspect the input and Choice logic; if the correct branch is selected but fails, inspect the target Lambda and its permissions.
  • Remove temporary lab resources when finished, including the state machine and individual Lambda functions.

Quick Reference Summary

  1. Upload the Lambda archive to CloudShell and extract the individual function ZIP files.
  2. Create a Lambda IAM role using the Lambda use case and AWSLambdaBasicExecutionRole.
  3. Replace the placeholder role ARN in the supplied AWS CLI commands.
  4. Run the aws lambda create-function commands for all five functions.
  5. Verify that the deployed Lambda code matches the supplied lab code.
  6. Replace every Lambda resource ARN in the Step Functions JSON definition.
  7. Import the JSON into a new Step Functions state machine.
  8. Review the code and visual editor, then create the state machine with the required permissions.
  9. Start executions with different document-type inputs.
  10. Confirm that the Choice state routes financial, HR, and generic documents to the appropriate processing function before finalization.
  11. Delete temporary resources after completing the lab.

Flashcards

Q: A workflow must invoke several Lambda functions and select one processing branch based on document data. Which AWS service should coordinate the workflow, and why?
A: AWS Step Functions should coordinate it because it defines the sequence, Choice branching, Lambda integrations, and execution history in one state machine.

Q: When would you use a Step Functions Choice state instead of a fixed sequential transition?
A: Use a Choice state when the next state depends on a value in the execution data, such as the document type in this lab.

Q: A Lambda creation command contains a placeholder role ARN. What must be done before running it?
A: Replace the placeholder with the ARN of the IAM role created for Lambda in the current account. The ARN must identify the correct environment.

Q: What policy is attached to the Lambda execution role in this lab, and what is its purpose?
A: AWSLambdaBasicExecutionRole is attached to provide the basic execution permissions required by the Lambda functions in the lab.

Q: What is the purpose of uploading and extracting the archive in AWS CloudShell?
A: CloudShell is used to obtain the separate ZIP packages for the individual Lambda functions and to run the AWS CLI creation commands.

Q: The state machine definition is logically correct but executions cannot invoke a task. What configuration should be checked first?
A: Check that the task’s Lambda resource ARN points to the correct function, account, and Region, and then check the relevant IAM permissions.

Q: How does the financial-document execution differ from the HR-document execution in this workflow?
A: Both begin with initial processing and use the document path decision, but the financial input routes to financial processing while the HR input routes to HR processing before finalization.

Q: Why should the Lambda code be inspected after creation even though the lab supplies ZIP files?
A: Inspection verifies that the expected package was deployed and that the function’s implementation corresponds to the workflow stage. The supplied archive should normally already contain the required code.

Q: What does the Step Functions visual editor provide during state machine creation?
A: It displays a graphical representation of the JSON-defined states and transitions, helping validate the workflow and identify definition errors.

Q: What information drives the branch selection in the lab?
A: The document type, represented in the execution data and examined by the workflow’s logic, drives selection of the financial, HR, or generic path.

Q: Why is testing multiple execution inputs important for this state machine?
A: A single successful execution validates only one route. Different document types test whether each branch and its Lambda integration are configured correctly.

Q: What is the distinction between Lambda and Step Functions in this design?
A: Lambda performs the individual processing actions, while Step Functions orchestrates those actions, controls transitions, and applies branching logic.

Q: After the lab is complete, which resources should be considered for cleanup?
A: Delete the Step Functions state machine and the individual Lambda functions if they are no longer needed for testing.

Practice Questions

Question 1

A state machine execution always follows the generic branch, even when the input is intended to represent an HR document. Which investigation is most appropriate first?

A. Replace all Lambda functions with EC2 instances
B. Inspect the document-type value in the execution input and the Choice conditions
C. Delete the IAM role and recreate it without policies
D. Upload the Lambda ZIP archive again without checking the definition

Correct answer: B

Explanation: Branch selection depends on the document-type data and the Choice logic. These should be checked before changing the compute platform or redeploying packages.

Question 2

An administrator imports the supplied state machine JSON, but a task fails because it cannot invoke the intended Lambda function. The JSON still contains the sample account number and Region. What is the best corrective action?

A. Update each Lambda resource ARN to the actual function ARN in the current account and Region
B. Change the document type to generic
C. Remove the Choice state
D. Attach AWSLambdaBasicExecutionRole to the Step Functions JSON file

Correct answer: A

Explanation: The state machine must reference the actual Lambda ARNs. Placeholder or incorrect account and Region values prevent the intended resource from being invoked.

Question 3

A lab participant needs to create five Lambda functions from supplied ZIP packages and run AWS CLI commands without opening a local terminal. Which tool best fits this task?

A. AWS CloudShell
B. The Step Functions visual editor only
C. IAM Access Analyzer
D. The Lambda function URL editor

Correct answer: A

Explanation: The lab specifically uses CloudShell to upload and extract the archive and execute the Lambda creation commands.

Question 4

An engineer wants to confirm that a financial input travels through initial processing, financial processing, and finalization. Which action provides the most direct validation?

A. Inspect only the IAM role name
B. Start a Step Functions execution with the financial document-type input and review the execution visualization
C. Recreate the Lambda functions with different names
D. Remove all resource ARNs from the state machine definition

Correct answer: B

Explanation: Starting an execution with the relevant input and reviewing the visual execution path directly confirms routing and state progression.

WordPress Metadata

Suggested Slug:
aws-step-functions-create-test-lambda-state-machine

Meta Description:
Learn how to provision Lambda functions, configure IAM permissions, import an AWS Step Functions state machine definition, and test Choice-based execution paths.

Tags:
AWS Step Functions, AWS Lambda, AWS IAM, AWS CloudShell, state machines, Choice state, Lambda execution role, Amazon States Language, workflow automation, SOA-C03