Bird
Raised Fist0
DynamoDBquery~20 mins

API Gateway to DynamoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
API Gateway to DynamoDB Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Architecture
intermediate
2:00remaining
Design flow of a request from API Gateway to DynamoDB

Which option correctly describes the flow of a read request from an API Gateway to DynamoDB in a serverless architecture?

AAPI Gateway receives the request, triggers a Lambda function which queries DynamoDB and returns the result to API Gateway, which then responds to the client.
BAPI Gateway directly queries DynamoDB and returns the result to the client without any intermediate processing.
CDynamoDB pushes data to API Gateway which then sends it to the client without any request from API Gateway.
DAPI Gateway stores data temporarily and then asynchronously sends it to DynamoDB without client waiting.
Attempts:
2 left
๐Ÿ’ก Hint

Think about how API Gateway interacts with backend services in a serverless setup.

โ“ scaling
intermediate
2:00remaining
Handling high read traffic from API Gateway to DynamoDB

You expect a sudden spike in read requests through API Gateway to DynamoDB. Which approach best helps handle this load without throttling?

ADisable DynamoDB Auto Scaling and rely on manual capacity increases only.
BIncrease API Gateway timeout to allow longer waits for DynamoDB responses.
CUse API Gateway to batch all requests into one large DynamoDB write operation.
DEnable DynamoDB Auto Scaling for read capacity and use API Gateway caching to reduce direct calls.
Attempts:
2 left
๐Ÿ’ก Hint

Think about how to reduce load on DynamoDB and automatically adjust capacity.

โ“ tradeoff
advanced
2:00remaining
Choosing between direct DynamoDB access and Lambda proxy integration

What is a key tradeoff when choosing to let API Gateway directly access DynamoDB versus using a Lambda function as a proxy?

ADirect access reduces latency but limits request validation and complex logic; Lambda adds flexibility but increases latency.
BDirect access increases cost significantly; Lambda is always cheaper regardless of usage.
CLambda cannot access DynamoDB securely; direct access is the only secure method.
DDirect access requires writing custom SDKs; Lambda uses built-in AWS SDKs automatically.
Attempts:
2 left
๐Ÿ’ก Hint

Consider flexibility versus speed in request handling.

๐Ÿง  Conceptual
advanced
2:00remaining
Understanding eventual consistency in DynamoDB with API Gateway

When API Gateway triggers a read from DynamoDB, which consistency model can cause the client to see stale data?

ADynamoDB does not support consistency models; API Gateway handles consistency.
BStrongly consistent reads can return stale data; eventually consistent reads always return the latest data.
CEventually consistent reads can return stale data; strongly consistent reads always return the latest data.
DBoth eventually and strongly consistent reads always return the latest data.
Attempts:
2 left
๐Ÿ’ก Hint

Think about how DynamoDB consistency models affect read freshness.

โ“ estimation
expert
2:00remaining
Estimating capacity for API Gateway to DynamoDB writes

Your API Gateway receives 10,000 write requests per minute, each writing 1 KB item to DynamoDB. What is the minimum write capacity units (WCUs) needed if each WCU supports 1 KB per second?

A10,000 WCUs
B167 WCUs
C600 WCUs
D1,000 WCUs
Attempts:
2 left
๐Ÿ’ก Hint

Calculate requests per second and relate to WCU definition.

Practice

(1/5)
1. What is the primary role of API Gateway when used with DynamoDB?
easy
A. To replace DynamoDB as a database
B. To store data directly in DynamoDB
C. To securely expose DynamoDB operations over HTTP
D. To perform complex data analytics on DynamoDB data

Solution

  1. Step 1: Understand API Gateway's function

    API Gateway acts as a secure interface that translates HTTP requests into backend service calls.
  2. Step 2: Identify its role with DynamoDB

    It exposes DynamoDB operations securely over HTTP, enabling controlled access and monitoring.
  3. Final Answer:

    To securely expose DynamoDB operations over HTTP -> Option C
  4. Quick Check:

    API Gateway = Secure HTTP access to DynamoDB [OK]
Hint: API Gateway acts as a secure HTTP front for DynamoDB [OK]
Common Mistakes:
  • Thinking API Gateway stores data
  • Confusing API Gateway with DynamoDB itself
  • Assuming API Gateway performs data analytics
2. Which of the following is the correct way to define a GET method in API Gateway to fetch an item from DynamoDB?
easy
A. Use HTTP GET with a path parameter for the key and integrate with DynamoDB GetItem action
B. Use HTTP POST with a JSON body containing the key and integrate with DynamoDB PutItem action
C. Use HTTP DELETE with query parameters and integrate with DynamoDB DeleteItem action
D. Use HTTP PUT with path parameters and integrate with DynamoDB UpdateItem action

Solution

  1. Step 1: Match HTTP method to DynamoDB action

    GET method is used to retrieve data, so it should map to DynamoDB's GetItem action.
  2. Step 2: Use path parameter for key

    The key identifying the item is passed as a path parameter in the GET request.
  3. Final Answer:

    Use HTTP GET with a path parameter for the key and integrate with DynamoDB GetItem action -> Option A
  4. Quick Check:

    GET + path key = GetItem [OK]
Hint: GET method fetches data; use path parameter for key [OK]
Common Mistakes:
  • Using POST instead of GET for fetching
  • Confusing PutItem with GetItem
  • Using wrong HTTP methods for actions
3. Given this API Gateway integration request mapping template snippet:
{
  "TableName": "Users",
  "Key": {
    "UserId": { "S": "$input.params('userId')" }
  }
}

What DynamoDB operation does this template prepare for?
medium
A. PutItem to insert a new user
B. GetItem to fetch a user by UserId
C. DeleteItem to remove a user
D. UpdateItem to modify user attributes

Solution

  1. Step 1: Analyze the template structure

    The template specifies a TableName and a Key with UserId, which matches the input for a GetItem request.
  2. Step 2: Match to DynamoDB operation

    GetItem requires TableName and Key to fetch an item; PutItem or UpdateItem would include Item or UpdateExpression fields.
  3. Final Answer:

    GetItem to fetch a user by UserId -> Option B
  4. Quick Check:

    TableName + Key = GetItem [OK]
Hint: TableName + Key in template means GetItem [OK]
Common Mistakes:
  • Confusing GetItem with PutItem
  • Assuming DeleteItem without DeleteExpression
  • Ignoring the Key field meaning
4. You configured API Gateway to integrate with DynamoDB PutItem but receive a 400 Bad Request error. Which of these is the most likely cause?
medium
A. Missing required 'Item' field in the request mapping template
B. Using HTTP GET method instead of POST
C. Incorrect table name in the DynamoDB action
D. Not enabling CORS on API Gateway

Solution

  1. Step 1: Understand PutItem requirements

    PutItem requires an 'Item' field specifying the data to insert; missing it causes a bad request.
  2. Step 2: Evaluate other options

    Using GET instead of POST may cause issues but usually not 400 if mapping is correct; wrong table name causes 500 errors; CORS issues cause client-side errors, not 400 from API Gateway.
  3. Final Answer:

    Missing required 'Item' field in the request mapping template -> Option A
  4. Quick Check:

    PutItem needs 'Item' field [OK]
Hint: PutItem must include 'Item' in request template [OK]
Common Mistakes:
  • Confusing HTTP method errors with mapping errors
  • Ignoring required fields in request templates
  • Assuming CORS causes 400 errors
5. You want to design a scalable API Gateway to DynamoDB system that supports thousands of requests per second with minimal latency. Which combination of design choices is best?
hard
A. Use API Gateway without caching, DynamoDB with provisioned capacity, and open access without authentication
B. Use API Gateway with caching disabled, DynamoDB with manual scaling, and no monitoring enabled
C. Use API Gateway with throttling disabled, DynamoDB with global tables disabled, and API keys for access control
D. Use API Gateway with caching enabled, DynamoDB with on-demand capacity mode, and IAM roles for secure access

Solution

  1. Step 1: Choose scalable DynamoDB capacity mode

    On-demand capacity mode automatically scales to handle high request volumes without manual intervention.
  2. Step 2: Enable API Gateway caching and secure access

    Caching reduces latency and load on DynamoDB; IAM roles provide secure, managed access.
  3. Step 3: Avoid options that disable throttling or monitoring

    Disabling throttling or monitoring risks overload and lack of visibility; open access is insecure.
  4. Final Answer:

    Use API Gateway with caching enabled, DynamoDB with on-demand capacity mode, and IAM roles for secure access -> Option D
  5. Quick Check:

    Caching + on-demand + IAM = scalable & secure [OK]
Hint: Enable caching and on-demand capacity for scalability [OK]
Common Mistakes:
  • Disabling throttling causing overload
  • Using provisioned capacity without scaling
  • Ignoring security best practices
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