0%
AWS Developer Associate (DVA-C03) Exam Prep: Development, Security, Testing, Deployment and Troubleshooting
How the Exam Works
Domain 2: Security
Domain 3: Testing and Deployment
Domain 4: Troubleshooting and Optimization
New in DVA-C03: Containers and AI
Final Review and Mock Exams
API Gateway for Developers
API Gateway is the front door for most serverless applications on the exam. It accepts HTTP or WebSocket requests, authenticates them, applies throttling, optionally transforms or caches them and forwards them to a backend such as Lambda, an HTTP endpoint or another AWS service. The developer exam tests it in depth: which API type supports which feature, how integrations shape the event your function receives, how stages and deployments work, how to secure an API and, above all, how to read the error codes it returns. This lesson works through each, from the developer's side.
Three API types
API Gateway offers three kinds of API, and choosing the wrong one is a common source of wrong answers because the feature sets differ.
REST APIs are the original and most featureful type. They support API keys and usage plans, response caching per stage, request validation against models, mapping templates written in Velocity Template Language, canary release settings on a stage, AWS WAF, resource policies, private APIs reachable only from a VPC, execution logging and X-Ray tracing. They support integrations with Lambda, HTTP endpoints, mock responses and direct AWS service actions, such as putting a message on an SQS queue without any function in between.
HTTP APIs are a newer, simpler type designed for the common case of proxying to Lambda or an HTTP backend. They cost substantially less per request and add less latency. They support JWT authorizers, which validate tokens from any OpenID Connect issuer including Cognito, as well as Lambda and IAM authorization, built in CORS configuration, automatic deployments and private integrations through VPC links to load balancers or Cloud Map services. They do not support response caching, API keys with usage plans, request validation or VTL mapping templates, though they do offer simpler parameter mapping to add, change or remove headers, query strings and paths.
WebSocket APIs keep a persistent, two way connection between a client and the API. They suit chat, live dashboards, multiplayer games and notifications, where the server must push messages without the client polling.
Choosing between REST and HTTP
The exam usually signals the choice through a required feature. If the stem needs caching at the gateway, per client quotas with API keys, request validation, VTL transformations, direct integration with a wide range of AWS service actions, WAF or a private API, the answer is a REST API. If it needs JWT validation against an OpenID Connect provider with little configuration, the lowest cost or the lowest latency for a simple Lambda proxy, the answer is an HTTP API.
When a stem says a team wants to reduce cost on an API that only proxies requests to Lambda and uses no REST specific features, migrating to an HTTP API is usually correct. When a stem says a team on an HTTP API now needs per customer usage quotas, an HTTP API cannot do it, and the answer involves a REST API.
Endpoint types for REST APIs
A REST API has an endpoint type. Edge optimized endpoints route requests through the CloudFront network to the API's Region, which helps globally distributed clients. Regional endpoints are reached directly in the Region, which suits clients in the same Region or teams that want to put their own CloudFront distribution in front with custom settings. Private endpoints are reachable only through an interface VPC endpoint, and a resource policy controls which VPCs or endpoints may call them. A stem that says an internal API must not be reachable from the internet points at a private REST API with a resource policy.
WebSocket APIs in more depth
A WebSocket API uses routes rather than resources and methods. The route selection expression tells API Gateway which field of an incoming message picks the route, commonly an action field in a JSON body. Three special routes exist. The connect route runs when a client opens a connection, which is where you authenticate and record the connection ID, typically in DynamoDB. The disconnect route runs when the connection closes, on a best effort basis, so clean up stale IDs with a TTL as well. The default route catches messages that match no other route.
To push a message to a client, the backend calls the connection management API with the connection ID, using the callback URL of the stage.
The backend needs IAM permission for execute-api:ManageConnections to make that call. If a client has disconnected, the call fails with a 410 Gone status, which is the signal to delete the stored connection ID. WebSocket connections close after a period of idleness, about ten minutes, and have a maximum duration of about two hours, so clients must be ready to reconnect.
Integration types
Behind each method or route sits an integration that defines where the request goes. For REST APIs the types are Lambda proxy, Lambda custom (non proxy), HTTP proxy, HTTP custom, AWS service, mock and VPC link for private resources behind a Network Load Balancer or, with newer VPC links, an Application Load Balancer. HTTP APIs offer Lambda proxy, HTTP proxy, a set of first class AWS service integrations such as SQS SendMessage and EventBridge PutEvents, and private integrations.
Mock integrations return a response defined in API Gateway without calling any backend. They are useful for prototyping, for health check endpoints, and for the OPTIONS preflight method that the console creates when you enable CORS on a REST API.
AWS service integrations are worth noticing. A REST API method can call SQS, DynamoDB, Step Functions, Kinesis or many other services directly, using an IAM role that API Gateway assumes. That removes a Lambda function whose only job was to forward the request. When a stem asks for the least code or lowest cost way to accept requests and put them on a queue, a direct service integration is often the answer.
Limits that matter
A few limits drive design. The maximum request payload is 10 MB; larger uploads should go directly to S3 with a presigned URL issued by the API. The integration timeout for REST APIs defaults to 29 seconds; for Regional and private REST APIs you can request a higher value, at the cost of lower throttling quotas. HTTP APIs allow up to 30 seconds. Work that takes longer must become asynchronous: accept the request, start the work through a queue, Step Functions or an asynchronous Lambda invocation, return 202 with a job ID, and let the client poll or receive a WebSocket notification. The next sections refer back to these numbers when they explain errors.
What the developer controls
For each method you configure four steps on a REST API: the method request, where authorization, required parameters and request validation live; the integration request, where the target and any mapping template live; the integration response, where backend errors map to status codes in non proxy integrations; and the method response, which declares the status codes, headers and models the method can return. In a proxy integration most of this collapses: API Gateway passes the request through and returns whatever the backend sends. Understanding which steps apply in each integration type is the key to the next section.
Exam trap: picking the API type by habit
Do not default to REST because it is older or to HTTP because it is cheaper. Read the stem for the feature it needs. A requirement for per client quotas, response caching, request validation or a private endpoint inside a VPC points to REST. A requirement for the lowest cost and latency with JWT validation from an external identity provider points to HTTP. A requirement for the server to push messages to connected clients points to WebSocket. When a stem lists several needs, pick the type that satisfies all of them, even if another type is cheaper, because a cheaper API that lacks a required feature is never the best answer. Custom domain names, Regional and edge optimized endpoints and Lambda integrations exist on more than one type, so they rarely decide the question on their own.
When a stem mentions caching, usage plans with API keys, request validation, VTL or a private API, choose a REST API. When it stresses lower cost, lower latency or JWT validation for a simple proxy, choose an HTTP API.