Bird
Raised Fist0
DynamoDBquery~20 mins

Step Functions with DynamoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Step Functions DynamoDB Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
What is the output of this DynamoDB query in Step Functions?

Consider a DynamoDB table named Orders with a partition key OrderId and an attribute Status. A Step Function executes a Query operation with the following parameters:

{
  "TableName": "Orders",
  "KeyConditionExpression": "OrderId = :oid",
  "ExpressionAttributeValues": {
    ":oid": {"S": "12345"}
  }
}

If the table contains one item with OrderId = "12345" and Status = "Shipped", what will the query return?

A{"Items": [], "Count": 0}
BRuntime error because Status attribute is not indexed
CSyntaxError due to missing FilterExpression
D{"Items": [{"OrderId": {"S": "12345"}, "Status": {"S": "Shipped"}}], "Count": 1}
Attempts:
2 left
💡 Hint

The query uses the partition key to find matching items.

🧠 Conceptual
intermediate
1:30remaining
Which Step Function state type is best to perform a DynamoDB update operation?

You want to update an item in a DynamoDB table as part of a Step Function workflow. Which state type should you use?

APass state to pass data without changes
BTask state with AWS SDK integration calling DynamoDB UpdateItem
CChoice state to decide which item to update
DWait state to delay the update operation
Attempts:
2 left
💡 Hint

Updating data requires an action that interacts with DynamoDB.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in this Step Function DynamoDB query state

Given this Step Function state snippet that queries DynamoDB, which option correctly identifies the syntax error?

{
  "Type": "Task",
  "Resource": "arn:aws:states:::aws-sdk:dynamodb:query",
  "Parameters": {
    "TableName": "Users",
    "KeyConditionExpression": "UserId = :uid",
    "ExpressionAttributeValues": {
      ":uid": {"S": "abc123"}
    }
  },
  "End": true
}
ANo syntax error; the state is valid
BKeyConditionExpression must use #uid instead of :uid
CExpressionAttributeValues keys must be strings without colon prefix
DMissing comma after ExpressionAttributeValues object
Attempts:
2 left
💡 Hint

Check the AWS SDK DynamoDB query syntax for Step Functions.

❓ optimization
advanced
2:30remaining
How to optimize a Step Function that scans a large DynamoDB table?

You have a Step Function that performs a Scan operation on a large DynamoDB table. The scan is slow and expensive. Which approach best optimizes this workflow?

AUse Query with a partition key filter instead of Scan
BIncrease the ScanLimit parameter to scan more items at once
CAdd a Wait state between scans to reduce throughput
DUse Scan with FilterExpression to reduce returned items
Attempts:
2 left
💡 Hint

Query operations are more efficient than Scan when possible.

🔧 Debug
expert
3:00remaining
Why does this Step Function DynamoDB PutItem state fail with a ValidationException?

Consider this Step Function state that tries to put an item into DynamoDB:

{
  "Type": "Task",
  "Resource": "arn:aws:states:::aws-sdk:dynamodb:putItem",
  "Parameters": {
    "TableName": "Products",
    "Item": {
      "ProductId": {"S": "p123"},
      "Price": {"N": "twenty"}
    }
  },
  "End": true
}

It fails with a ValidationException. What is the cause?

ATableName parameter is case-sensitive and should be "products"
BMissing required attribute ProductName in the item
CThe Price attribute value "twenty" is not a valid number format
DResource ARN is incorrect for PutItem operation
Attempts:
2 left
💡 Hint

Check the data types expected by DynamoDB for number attributes.

Practice

(1/5)
1. What is the main purpose of using AWS Step Functions with DynamoDB?
easy
A. To automate workflows that involve storing and retrieving data step by step
B. To create visual dashboards for DynamoDB data
C. To replace DynamoDB with a different database
D. To manually update DynamoDB tables without code

Solution

  1. Step 1: Understand Step Functions role

    Step Functions help run tasks in a specific order automatically.
  2. Step 2: Connect with DynamoDB usage

    DynamoDB stores data quickly and safely, and Step Functions can automate tasks that read or write this data.
  3. Final Answer:

    To automate workflows that involve storing and retrieving data step by step -> Option A
  4. Quick Check:

    Step Functions + DynamoDB = automated data workflows [OK]
Hint: Step Functions automate tasks; DynamoDB stores data fast [OK]
Common Mistakes:
  • Thinking Step Functions create dashboards
  • Believing Step Functions replace DynamoDB
  • Assuming manual updates are the main use
2. Which of the following is the correct Resource ARN for a DynamoDB operation (e.g., PutItem) in a Step Functions state using Amazon States Language (ASL)?
easy
A. "Resource": "arn:aws:s3:::TableName"
B. "Resource": "dynamodb://TableName"
C. "Resource": "arn:aws:states:::dynamodb:putItem"
D. "Resource": "lambda:TableName"

Solution

  1. Step 1: Identify correct ARN format for DynamoDB

    Step Functions uses optimized integrations for DynamoDB with ARNs starting with "arn:aws:states:::dynamodb:" followed by the action like putItem.
  2. Step 2: Check options for correct ARN

    "Resource": "arn:aws:states:::dynamodb:putItem" matches the correct optimized integration format; others reference wrong services or formats.
  3. Final Answer:

    "Resource": "arn:aws:states:::dynamodb:putItem" -> Option C
  4. Quick Check:

    Step Functions DynamoDB ARN = "arn:aws:states:::dynamodb:putItem" [OK]
Hint: Step Functions DynamoDB ARNs: arn:aws:states:::dynamodb:[action] [OK]
Common Mistakes:
  • Using S3 or Lambda ARNs for DynamoDB
  • Using URL-like syntax instead of ARN
  • Missing optimized integration format
3. Given this Step Functions task state calling DynamoDB PutItem:
{
  "Type": "Task",
  "Resource": "arn:aws:states:::dynamodb:putItem",
  "Parameters": {
    "TableName": "Users",
    "Item": {
      "UserId": {"S": "123"},
      "Name": {"S": "Alice"}
    }
  },
  "End": true
}
What will happen when this state runs?
medium
A. It will add a new item with UserId 123 and Name Alice to the Users table
B. It will delete the item with UserId 123 from the Users table
C. It will update the Name of UserId 123 only if it exists
D. It will cause a syntax error and fail

Solution

  1. Step 1: Understand the PutItem action

    PutItem adds a new item or replaces an existing item in DynamoDB with the given attributes.
  2. Step 2: Analyze the Parameters

    The Parameters specify the table "Users" and an item with UserId "123" and Name "Alice" to be added.
  3. Final Answer:

    It will add a new item with UserId 123 and Name Alice to the Users table -> Option A
  4. Quick Check:

    PutItem adds or replaces item = It will add a new item with UserId 123 and Name Alice to the Users table [OK]
Hint: PutItem adds or replaces items in DynamoDB [OK]
Common Mistakes:
  • Confusing PutItem with DeleteItem
  • Thinking PutItem only updates existing items
  • Assuming syntax error without checking JSON
4. You have this Step Functions state to get an item from DynamoDB:
{
  "Type": "Task",
  "Resource": "arn:aws:states:::dynamodb:getItem",
  "Parameters": {
    "TableName": "Orders",
    "Key": {
      "OrderId": {}
    }
  },
  "End": true
}
What is the problem with this state?
medium
A. TableName should be lowercase
B. The Resource ARN is incorrect for getItem
C. End cannot be true in a Task state
D. The Key value for OrderId is empty, causing a runtime error

Solution

  1. Step 1: Check the Key parameter

    The Key must have a valid AttributeValue (with type like S/N); here OrderId is an empty object {}, which is invalid for DynamoDB keys.
  2. Step 2: Validate other parameters

    Resource ARN is correct, TableName case is fine, and End:true is allowed in Task states.
  3. Final Answer:

    The Key value for OrderId is empty, causing a runtime error -> Option D
  4. Quick Check:

    Empty key value causes error = The Key value for OrderId is empty, causing a runtime error [OK]
Hint: DynamoDB keys must have non-empty values [OK]
Common Mistakes:
  • Thinking ARN is wrong
  • Believing TableName must be lowercase
  • Assuming End:true is invalid
5. You want to create a Step Functions workflow that first writes a new user to DynamoDB, then reads the user back to confirm. Which sequence of states correctly achieves this?
hard
A. First a Task state with arn:aws:states:::dynamodb:getItem, then a Task state with arn:aws:states:::dynamodb:putItem
B. First a Task state with Resource arn:aws:states:::dynamodb:putItem, then a Task state with arn:aws:states:::dynamodb:getItem
C. A single Task state with arn:aws:states:::dynamodb:updateItem
D. Two parallel states both using arn:aws:states:::dynamodb:putItem

Solution

  1. Step 1: Determine the write then read order

    You must first add the user with putItem, then read it with getItem to confirm.
  2. Step 2: Check the options for correct sequence

    First a Task state with Resource arn:aws:states:::dynamodb:putItem, then a Task state with arn:aws:states:::dynamodb:getItem correctly sequences putItem followed by getItem; others have wrong order or wrong actions.
  3. Final Answer:

    First a Task state with Resource arn:aws:states:::dynamodb:putItem, then a Task state with arn:aws:states:::dynamodb:getItem -> Option B
  4. Quick Check:

    Write then read = First a Task state with Resource arn:aws:states:::dynamodb:putItem, then a Task state with arn:aws:states:::dynamodb:getItem [OK]
Hint: Write with putItem before reading with getItem [OK]
Common Mistakes:
  • Reading before writing
  • Using updateItem instead of putItem
  • Running writes in parallel without read
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