Based on the DVA-C02 exam guideReport an error
The API Gateway we covered in Week 4 is not a simple HTTP proxy. Three independent product families — REST API, HTTP API, and WebSocket API — implement different paradigms, each with different authentication methods, integration types, and performance characteristics. This review focuses less on reconfirming individual concepts and more on edge cases and selection judgment. DVA-C02 asks not "which service should I use" but "why is this configuration wrong" and "what is the root cause of this error". The scenario questions below are structured with the same kind of compound conditions that appear on the actual exam.
| Feature | REST API | HTTP API | WebSocket API |
|---|---|---|---|
| Protocol | HTTP/1.1 | HTTP/1.1 | RFC 6455 WebSocket |
| Communication direction | Request-response | Request-response | Bidirectional |
| Cost (per million calls) | ~$3.50 | ~$1.00 | Connection time + message count |
| Lambda Proxy integration | ✅ | ✅ | ✅ |
| VTL mapping templates | ✅ | ❌ | ❌ |
| Direct AWS Service integration | ✅ | ❌ | ❌ |
| MOCK integration | ✅ | ❌ | ❌ |
| IAM authentication | ✅ | ✅ | ✅ |
| Lambda Authorizer | ✅ | ✅ | ✅ ($connect only) |
| Cognito User Pool Authorizer | ✅ | ❌ | ❌ |
| JWT Authorizer | ❌ | ✅ | ❌ |
| API Key + Usage Plan | ✅ | ❌ | ❌ |
| Resource Policy | ✅ | ❌ | ❌ |
| mTLS | ✅ | ✅ | ❌ |
| WAF | ✅ (direct) | ❌ (CF workaround) | ❌ |
| Response caching | ✅ | ❌ | ❌ |
| Request Validation | ✅ | ❌ | ❌ |
| Gateway Response customization | ✅ | ❌ | ❌ |
| X-Ray Tracing | ✅ | ❌ | ❌ |
| Canary Deployment | ✅ | ❌ | ❌ |
| VPC Link backend | NLB only | ALB/NLB/CloudMap | ❌ |
| Automatic CORS setup | ❌ (manual) | ✅ | N/A |
| Payload Format | Lambda Proxy format | v1.0 or v2.0 (default) | Separate |
| Scenario | Recommended auth method |
|---|---|
| AWS Lambda/EC2 calling an API in another account | IAM + SigV4 |
| External OAuth2 / custom JWT validation | Lambda Authorizer (TOKEN) |
| Composite validation of header + query + path | Lambda Authorizer (REQUEST) |
| Cognito User Pool users (REST API) | Cognito User Pool Authorizer |
| Cognito/Auth0/Okta JWT (HTTP API) | JWT Authorizer |
| Partner API usage tracking + quota | API Key + Usage Plan |
| Allow access only from inside a VPC | Resource Policy (SourceVpce) |
| IP whitelist | Resource Policy (SourceIp) |
| Cross-account API access | Resource Policy (Principal ARN) |
| IoT device, B2B partner authentication | mTLS |
| SQL injection / XSS defense | WAF (REST API only, direct) |
| Scenario | Integration type |
|---|---|
| Connect Lambda in the simplest way | AWS_PROXY (Lambda Proxy) |
| Transform the Lambda response before returning to the client | AWS (non-Proxy) + response mapping |
| Call DynamoDB/SNS/SQS directly (without Lambda) | AWS (non-Proxy) + VTL |
| Proxy an external HTTP server | HTTP_PROXY |
| External HTTP server + response transformation | HTTP + response mapping |
| Hardcoded response for dev/test | MOCK |
| Metric | What it measures | Use |
|---|---|---|
Latency | Client receipt ~ response returned (end-to-end) | Overall performance monitoring |
IntegrationLatency | API GW → backend call ~ response | Isolate backend performance |
Count | Total number of API calls | Traffic trends |
4XXError | Client errors like 400/401/403/429 | Detect misuse/auth failure/throttling |
5XXError | Server errors like 500/502/503/504 | Detect backend failures/timeouts |
CacheHitCount | Number of times served from cache | Cache efficiency |
CacheMissCount | Number of times a backend call was needed | Cache efficiency |
If Latency - IntegrationLatency is large, API GW internal processing (auth, VTL, cache lookup) is the bottleneck. If IntegrationLatency itself is large, the backend is slow.
Without a deploy, changes don't apply: In REST API, even if you change resources, methods, integrations, or authorizers, they aren't reflected unless you redeploy to the stage. HTTP API deploys automatically.
An API key is not authentication: The x-api-key header is for client identification and usage tracking. Do not mistake it for a security mechanism. An API key alone does not provide authorization.
The ACM certificate for an Edge-Optimized API must be in us-east-1: Since traffic to an Edge-Optimized endpoint flows through CloudFront, the custom domain's SSL/TLS certificate must be created in us-east-1 ACM. Regional/Private use the ACM of that region.
WAF can be attached directly only to REST API: You cannot attach a WAF Web ACL directly to HTTP API. You must use the workaround of placing CloudFront in front and attaching WAF to CloudFront.
The event structure of HTTP API Payload v2.0 is different: It has no httpMethod, resource, or path fields. Attaching an existing REST API Lambda as-is causes a KeyError. Set payloadFormatVersion: "1.0" or modify the code.
You must specify the cache key for a Lambda Authorizer REQUEST type: If you don't specify a cache key, caching doesn't work and the Authorizer Lambda is invoked on every request.
A Lambda Proxy response body must be a string: You must call json.dumps(); if you put a dict object directly, API Gateway can't serialize it.
WebSocket $disconnect execution is not guaranteed: On a forced network termination, $disconnect may not run. You must automatically clean up stale connections with a DynamoDB TTL.
WebSocket Idle Timeout 10 min, Max Duration 2 hours: Exceeding these limits forcibly terminates the connection. Clients can prevent the idle timeout with Ping/Pong.
Cache invalidation (InvalidateCache) requires an IAM permission: If you enable requireAuthorizationForCacheControl on the stage, a client without the execute-api:InvalidateCache permission gets a 403 even when sending Cache-Control: max-age=0.
CORS is handled by a different party depending on the integration type: In Lambda Proxy, Lambda must return the CORS headers directly. Under AWS_PROXY, API Gateway does not automatically add CORS headers. Using a Gateway Response, you can add CORS headers even to API Gateway's own errors (including 4XX).
DynamoDB direct-integration VTL must handle the DynamoDB type system: DynamoDB responses are in {"S": "value"}, {"N": "123"} format. If you don't parse this into clean JSON in VTL, the client receives DynamoDB's internal format as-is.
| Domain | Related Week 4 topics | Weight |
|---|---|---|
| Domain 1: Development with AWS Services | Lambda Proxy integration, VTL, DynamoDB direct integration | 32% |
| Domain 2: Security | SigV4, Lambda Authorizer, Cognito Authorizer, Resource Policy, WAF, mTLS | 26% |
| Domain 3: Deployment | Stages, canary deployment, SAM integration, Stage Variables | 24% |
| Domain 4: Troubleshooting | Latency vs IntegrationLatency, causes of 429/504/502 errors, Authorizer cache | 18% |
Click a choice to reveal the answer and explanation.
Question 1
A startup provides an API to external partners. Partner A must be limited to 100,000 calls per month and Partner B to 500,000 per month. Also, Partner B needs a rate limit of 100 requests/second and Partner A 20 requests/second. What is the most appropriate configuration?
Question 2
A company's REST API Lambda function depends on an external payment service. In CloudWatch, 5XXError is increasing, Latency is close to 29 seconds, and IntegrationLatency is also close to 29 seconds. What is the most likely cause?
Question 3
A dev team implemented a DynamoDB direct integration (VTL) on a REST API. API Gateway calls DynamoDB GetItem and returns the response to the client. The client developer complained that the response comes in the format {"Item": {"name": {"S": "Hong Gildong"}, "age": {"N": "30"}}}. How do you fix this?
Question 4
A mobile app queries data through an API Gateway REST API. It authenticates with a Cognito User Pool. You want to reduce Lambda calls when the same user repeatedly queries the same data. You enabled response caching, but a problem arose where all users share the same cached value. What is the cause and solution?
Question 5
You're building a real-time stock trading alert system. When a trader connects from a web browser, the server must push price changes immediately. The trader has no need to send messages to the server. What is the most suitable architecture?
Question 6
A company wants to configure WAF on a REST API to block SQL injection. However, some legitimate requests are also being blocked. The team wants to analyze the pattern of blocked requests and fine-tune the WAF rules. Which WAF setting should they enable?
Question 7
A startup wants to deploy a Next.js backend API to AWS. Each API path is split into a separate Lambda, and the requirements are: (1) low cost, (2) Cognito-based JWT authentication, (3) automatic CORS setup, (4) a custom domain. Which API type is most suitable?
Question 8
There's an API using a Lambda Authorizer (TOKEN type, TTL 300 seconds). The security team requests that a specific user's JWT token be invalidated immediately. The token has not yet expired. What is the fastest way?
Question 9
In a WebSocket API-based real-time chat, you must broadcast a message only to users in a specific chat room. There's a connection registry in DynamoDB. What is the most efficient DynamoDB lookup method?
Question 10
A team uses API Gateway HTTP API with Lambda integration. The existing Lambda code was code that worked on REST API, reading the client IP with event["requestContext"]["identity"]["sourceIp"]. After switching to HTTP API, an error occurs in that code. What is the root cause and solution?
| Question type | Included questions | If you need to relearn |
|---|---|---|
| Authentication method selection | 1, 8 | Day 18 |
| Integration types & VTL | 3 | Day 17 |
| Caching & throttling | 4, 1 | Day 18 |
| Real-time communication design | 5, 9 | Day 19 |
| API type selection | 7 | Day 16, 19 |
| Troubleshooting (metrics) | 2 | Day 18 |
| WAF & security | 6 | Day 18 |
| Payload Format | 10 | Day 19 |
| Score | Assessment |
|---|---|
| 9-10 | Complete understanding of API Gateway. Proceed to Week 5 |
| 7-8 | Excellent. Recheck the Day file for the questions you missed |
| 5-6 | Good. Re-familiarize with the Week 4 Day 16-19 traps checklist |
| 3-4 | Fair. Relearning all of Day 16-19 is recommended |
| 0-2 | You need to relearn Week 4 from the beginning |