Bird
0
0

What will be the output of this Step Functions state machine if the input is {"numbers": [1,2,3]}? It uses a Map state to multiply each number by 2.

medium📝 Predict Output Q5 of 15
AWS - Serverless Architecture
What will be the output of this Step Functions state machine if the input is {"numbers": [1,2,3]}? It uses a Map state to multiply each number by 2.
{
  "StartAt": "MultiplyMap",
  "States": {
    "MultiplyMap": {
      "Type": "Map",
      "ItemsPath": "$.numbers",
      "Iterator": {
        "StartAt": "Multiply",
        "States": {
          "Multiply": {
            "Type": "Task",
            "Resource": "arn:aws:lambda:region:account:function:multiplyByTwo",
            "End": true
          }
        }
      },
      "End": true
    }
  }
}
AThe output is [1, 2, 3]
BThe output is [2, 4, 6]
CThe output is an error due to missing Next field
DThe output is [3, 6, 9]
Step-by-Step Solution
Solution:
  1. Step 1: Understand Map state behavior

    The Map state runs the iterator for each item in the input array, here multiplying each number by two.
  2. Step 2: Apply the Lambda function to each item

    Input numbers [1,2,3] each get multiplied by 2, resulting in [2,4,6].
  3. Final Answer:

    The output is [2, 4, 6] -> Option B
  4. Quick Check:

    Map state output = doubled array [OK]
Quick Trick: Map runs iterator on each item, transforming the list [OK]
Common Mistakes:
  • Confusing input and output arrays
  • Expecting errors from missing Next in iterator end states

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes