Bird
Raised Fist0
AWScloud~10 mins

Step Functions for workflows in AWS - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the type of the Step Function state.

AWS
"Type": "[1]"
Drag options to blanks, or click blank then click option'
AQueue
BTask
CLambda
DBucket
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Bucket' or 'Queue' which are AWS services but not Step Function state types.
Using 'Lambda' as a type instead of 'Task'.
2fill in blank
medium

Complete the code to specify the next state in the workflow.

AWS
"Next": "[1]"
Drag options to blanks, or click blank then click option'
AProcessData
BStartState
CEndState
DInitialize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'EndState' which is usually a terminal state, not a next step.
Using 'StartState' which is the first state, not the next.
3fill in blank
hard

Fix the error in the state definition by completing the missing field.

AWS
"End": [1]
Drag options to blanks, or click blank then click option'
A"true"
BTrue
C"True"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Putting true in quotes, making it a string instead of boolean.
Using capitalized True which is invalid in JSON.
4fill in blank
hard

Fill both blanks to define a Task state with a Lambda function resource and mark it as the end state.

AWS
{
  "Type": "[1]",
  "Resource": "[2]",
  "End": true
}
Drag options to blanks, or click blank then click option'
ATask
Barn:aws:s3:::mybucket
Carn:aws:lambda:us-east-1:123456789012:function:MyFunction
DChoice
Attempts:
3 left
💡 Hint
Common Mistakes
Using S3 bucket ARN as Resource instead of Lambda ARN.
Using Choice as Type which is for branching, not tasks.
5fill in blank
hard

Fill all three blanks to create a Choice state that routes based on a variable's value.

AWS
{
  "Type": "Choice",
  "Choices": [
    {
      "Variable": "[1]",
      "StringEquals": "[2]",
      "Next": "[3]"
    }
  ]
}
Drag options to blanks, or click blank then click option'
A$.status
BCompleted
CSuccessState
D$.result
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong JSON path for Variable.
Using a state name that does not exist for Next.
Putting values in wrong fields.

Practice

(1/5)
1. What is the main purpose of AWS Step Functions in a workflow?
easy
A. To monitor network traffic between AWS services
B. To coordinate and manage the sequence of tasks in a workflow
C. To provide a user interface for AWS services
D. To store large amounts of data for applications

Solution

  1. Step 1: Understand the role of Step Functions

    AWS Step Functions help organize and control the order of tasks in a workflow, making sure each step runs in sequence or parallel as needed.
  2. Step 2: Compare with other AWS services

    Other options describe storage, UI, or monitoring, which are not the main functions of Step Functions.
  3. Final Answer:

    To coordinate and manage the sequence of tasks in a workflow -> Option B
  4. Quick Check:

    Step Functions = task coordination [OK]
Hint: Step Functions organize tasks step-by-step [OK]
Common Mistakes:
  • Confusing Step Functions with storage services
  • Thinking Step Functions provide UI
  • Assuming Step Functions monitor network traffic
2. Which JSON field is required to define a task state in an AWS Step Functions state machine?
easy
A. "Timeout" specifying the maximum execution time
B. "Retry" specifying the retry policy
C. "InputPath" specifying the input data format
D. "Resource" specifying the ARN of the task to run

Solution

  1. Step 1: Identify the key field for task execution

    The "Resource" field is mandatory in a task state to specify which AWS service or Lambda function to invoke.
  2. Step 2: Understand other fields

    "Timeout", "InputPath", and "Retry" are optional fields that control behavior but are not required to define a task.
  3. Final Answer:

    "Resource" specifying the ARN of the task to run -> Option D
  4. Quick Check:

    Task state needs "Resource" [OK]
Hint: "Resource" points to the task to run [OK]
Common Mistakes:
  • Confusing optional fields with required ones
  • Using "Timeout" as a required field
  • Forgetting to specify the task ARN
3. Given this Step Functions snippet, what is the next state after TaskA completes successfully?
{
  "StartAt": "TaskA",
  "States": {
    "TaskA": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:region:123456789012:function:FunctionA",
      "Next": "TaskB"
    },
    "TaskB": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:region:123456789012:function:FunctionB",
      "End": true
    }
  }
}
medium
A. TaskB
B. TaskA
C. End state
D. No next state defined

Solution

  1. Step 1: Read the "Next" field of TaskA

    The JSON shows "Next": "TaskB" for TaskA, meaning after TaskA finishes, the workflow moves to TaskB.
  2. Step 2: Confirm TaskB is defined

    TaskB is defined and marked with "End": true, so it is the final step after TaskA.
  3. Final Answer:

    TaskB -> Option A
  4. Quick Check:

    TaskA's "Next" = TaskB [OK]
Hint: Check the "Next" field for the following state [OK]
Common Mistakes:
  • Assuming TaskA loops to itself
  • Thinking workflow ends after TaskA
  • Ignoring the "Next" field
4. You have this Step Functions state definition:
{
  "Type": "Task",
  "Resource": "arn:aws:lambda:region:123456789012:function:MyFunction",
  "Next": "NextState"
}
What is missing that could cause a failure if the Lambda function errors?
medium
A. "Catch" block to handle errors
B. "TimeoutSeconds" field to limit execution time
C. "ResultPath" to store output
D. "StartAt" field to define the first state

Solution

  1. Step 1: Identify error handling in Step Functions

    Without a "Catch" block, errors from the Lambda function cause the workflow to fail immediately.
  2. Step 2: Understand other fields

    "TimeoutSeconds" limits time but is optional; "ResultPath" controls output storage; "StartAt" is for the state machine root, not individual states.
  3. Final Answer:

    "Catch" block to handle errors -> Option A
  4. Quick Check:

    Error handling needs "Catch" [OK]
Hint: Add "Catch" to handle task errors safely [OK]
Common Mistakes:
  • Confusing "TimeoutSeconds" with error handling
  • Omitting "Catch" causes workflow failure on error
  • Thinking "StartAt" is needed inside a task
5. You want to build a workflow that runs two Lambda functions in parallel and then proceeds only when both finish successfully. Which Step Functions state type should you use?
hard
A. Map state
B. Choice state
C. Parallel state
D. Pass state

Solution

  1. Step 1: Understand the requirement for parallel execution

    Running two Lambda functions at the same time and waiting for both to finish requires a "Parallel" state.
  2. Step 2: Review other state types

    "Choice" is for branching decisions, "Map" is for iterating over items, and "Pass" passes data without work.
  3. Final Answer:

    Parallel state -> Option C
  4. Quick Check:

    Parallel state runs tasks simultaneously [OK]
Hint: Use Parallel state to run tasks together [OK]
Common Mistakes:
  • Using Choice state for parallelism
  • Confusing Map state with parallel execution
  • Thinking Pass state runs tasks
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard