Practice
1. What is the primary role of API Gateway when used with DynamoDB?
easy
Solution
Step 1: Understand API Gateway's function
API Gateway acts as a secure interface that translates HTTP requests into backend service calls.Step 2: Identify its role with DynamoDB
It exposes DynamoDB operations securely over HTTP, enabling controlled access and monitoring.Final Answer:
To securely expose DynamoDB operations over HTTP -> Option CQuick 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
Solution
Step 1: Match HTTP method to DynamoDB action
GET method is used to retrieve data, so it should map to DynamoDB's GetItem action.Step 2: Use path parameter for key
The key identifying the item is passed as a path parameter in the GET request.Final Answer:
Use HTTP GET with a path parameter for the key and integrate with DynamoDB GetItem action -> Option AQuick 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:
What DynamoDB operation does this template prepare for?
{
"TableName": "Users",
"Key": {
"UserId": { "S": "$input.params('userId')" }
}
}What DynamoDB operation does this template prepare for?
medium
Solution
Step 1: Analyze the template structure
The template specifies a TableName and a Key with UserId, which matches the input for a GetItem request.Step 2: Match to DynamoDB operation
GetItem requires TableName and Key to fetch an item; PutItem or UpdateItem would include Item or UpdateExpression fields.Final Answer:
GetItem to fetch a user by UserId -> Option BQuick 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
Solution
Step 1: Understand PutItem requirements
PutItem requires an 'Item' field specifying the data to insert; missing it causes a bad request.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.Final Answer:
Missing required 'Item' field in the request mapping template -> Option AQuick 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
Solution
Step 1: Choose scalable DynamoDB capacity mode
On-demand capacity mode automatically scales to handle high request volumes without manual intervention.Step 2: Enable API Gateway caching and secure access
Caching reduces latency and load on DynamoDB; IAM roles provide secure, managed access.Step 3: Avoid options that disable throttling or monitoring
Disabling throttling or monitoring risks overload and lack of visibility; open access is insecure.Final Answer:
Use API Gateway with caching enabled, DynamoDB with on-demand capacity mode, and IAM roles for secure access -> Option DQuick 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
