All exams← All AWS Developer Associate (DVA-C02) notes

Serverless (Lambda, API Gateway, DynamoDB): AWS Developer Associate (DVA-C02) revision notes

Revision notes

Lambda basics

Lambda runs your code without servers, billed per millisecond of execution (rounded up) plus memory allocated. You pick memory from 128 MB to 10,240 MB, and CPU scales proportionally with memory - more memory means more CPU. Default timeout is 3 seconds, maximum is 15 minutes. Deployment package (zip) limit is 50 MB zipped / 250 MB unzipped including layers; container images can go up to 10 GB.

Cold starts and concurrency

A 'cold start' happens when Lambda provisions a fresh execution environment - this adds latency, worse for languages like Java or .NET. Provisioned concurrency keeps environments warm for predictable latency, at extra cost. Reserved concurrency caps how many concurrent executions a function can use, protecting downstream systems and other functions from being starved. Default account concurrency limit is 1,000 (soft limit, raisable).

Environment and state

Use environment variables for config; encrypt sensitive ones with KMS. Lambda is stateless between invocations but the execution environment can be reused, so anything initialised outside the handler (like a DB connection) persists across warm invocations - a common exam trap.

API Gateway

Supports REST APIs (more features, usage plans, API keys) and HTTP APIs (cheaper, faster, simpler, no usage plans). Integrates with Lambda via Lambda proxy integration, passing the full request and expecting a specific JSON response shape (statusCode, headers, body). Throttling defaults to 10,000 requests/second steady-state with a 5,000 burst, account-wide - configurable per method. Caching is REST-API only, not HTTP API.

DynamoDB essentials

A NoSQL key-value/document store. Partition key alone, or partition key + sort key, forms the primary key. Read/write capacity modes: on-demand (pay per request, scales automatically) or provisioned (set RCU/WCU, can use auto scaling). One RCU = one strongly consistent read of up to 4 KB/second (or two eventually consistent reads). One WCU = one write of up to 1 KB/second. Item size limit is 400 KB.

DynamoDB features to know

DAX is an in-memory cache for DynamoDB, cutting read latency to microseconds - it sits in front, transparent to your app code. Streams capture item-level changes and can trigger Lambda functions. Global Secondary Indexes (GSI) can use different partition/sort keys and have their own capacity; Local Secondary Indexes (LSI) share the base table's partition key and must be created at table creation time.

Common mistakes

Don't confuse Lambda timeout (max 15 min) with API Gateway's own 29-second maximum integration timeout - a long Lambda behind API Gateway will still fail after 29 seconds. Don't forget IAM execution roles - Lambda needs a role attached even if it does nothing but write logs. Remember DynamoDB is eventually consistent by default unless you explicitly request strongly consistent reads.

Key facts

Flashcards

What is the maximum timeout for a Lambda function?
15 minutes (900 seconds); default is 3 seconds.
tap to reveal
What is API Gateway's maximum integration timeout?
29 seconds, regardless of the Lambda function's own timeout setting.
tap to reveal
What is the memory range for a Lambda function?
128 MB to 10,240 MB; CPU allocation scales proportionally with memory.
tap to reveal
What is the maximum size of a DynamoDB item?
400 KB.
tap to reveal
What does one DynamoDB RCU provide?
One strongly consistent read per second of up to 4 KB (or two eventually consistent reads of the same size).
tap to reveal
What does one DynamoDB WCU provide?
One write per second of up to 1 KB.
tap to reveal
What is the key difference between a GSI and an LSI in DynamoDB?
A GSI can use different partition and sort keys and be added anytime; an LSI shares the base table's partition key and must be defined at table creation.
tap to reveal
What does DAX do?
Provides an in-memory cache in front of DynamoDB for microsecond read latency, transparent to application code.
tap to reveal
What is the difference between reserved and provisioned concurrency in Lambda?
Reserved concurrency caps the max concurrent executions for a function; provisioned concurrency pre-initialises environments to eliminate cold starts.
tap to reveal
What is the Lambda deployment package size limit?
50 MB zipped, 250 MB unzipped including layers; container images can be up to 10 GB.
tap to reveal
What triggers a Lambda cold start?
Provisioning a brand-new execution environment, which adds startup latency - worse for runtimes like Java or .NET.
tap to reveal
What is the difference between REST APIs and HTTP APIs in API Gateway?
REST APIs offer more features (usage plans, API keys, caching) at higher cost; HTTP APIs are cheaper and faster but lack caching and usage plans.
tap to reveal
How does Lambda handle state between invocations?
It is stateless between invocations, but code initialised outside the handler (e.g. a DB connection) can persist across warm executions of the same environment.
tap to reveal
What are the two DynamoDB capacity modes?
On-demand (pay per request, auto-scales) and provisioned (set RCU/WCU, optionally with auto scaling).
tap to reveal
Practice questions

Serverless (Lambda, API Gateway, DynamoDB): 5 practice questions

Q1. A Lambda function needs to read a database password at runtime without storing it in plaintext environment variables. Which approach is BEST practice?
  • A.  Store the password in a public S3 bucket and download it on cold start
  • B.  Store the password in an encrypted Lambda environment variable using a customer managed KMS key, or retrieve it from Secrets Manager at invocation time
  • C.  Hardcode the password in the function code and rely on IAM to restrict who can view the console
  • D.  Pass the password as a query string parameter on every API Gateway request
Show answer & explanation
✓ Answer: B. Store the password in an encrypted Lambda environment variable using a customer managed KMS key, or retrieve it from Secrets Manager at invocation time
Lambda environment variables can be encrypted with a customer managed CMK, and Secrets Manager is purpose-built for rotating credentials retrieved at runtime. Hardcoding in code or exposing via S3/query strings leaks the secret to anyone with code or network access.
Q2. An API Gateway REST API integrates with a Lambda function using the AWS_PROXY integration type. What is true about the event and response format in this setup?
  • A.  Lambda must return an XML document that API Gateway converts to JSON
  • B.  The developer must write a full Velocity Template Language mapping to pass the request to Lambda
  • C.  Lambda receives a fixed event structure containing headers, path, query parameters and body, and must return a response object with statusCode, headers and body
  • D.  API Gateway automatically maps the entire request body to individual Lambda function parameters
Show answer & explanation
✓ Answer: C. Lambda receives a fixed event structure containing headers, path, query parameters and body, and must return a response object with statusCode, headers and body
Lambda proxy integration passes the entire request as a standardised event object and requires the function to return an object with statusCode, headers and body. VTL mapping templates are used for non-proxy (custom) integrations, not proxy integrations.
Q3. A DynamoDB table uses on-demand capacity mode. A sudden spike sends traffic to roughly double the previous peak within a few minutes. What happens?
  • A.  Requests are silently dropped and no error is returned to the client
  • B.  The table stops accepting writes until a support ticket increases capacity
  • C.  DynamoDB automatically switches the table to provisioned mode to handle the spike
  • D.  DynamoDB scales automatically to accommodate the new peak without manual provisioning, though a brief throttling window can occur if traffic more than doubles the previous peak in under 30 minutes
Show answer & explanation
✓ Answer: D. DynamoDB scales automatically to accommodate the new peak without manual provisioning, though a brief throttling window can occur if traffic more than doubles the previous peak in under 30 minutes
On-demand tables scale to serve up to double the previous traffic peak within 30 minutes; exceeding that rate can cause brief throttling until DynamoDB adapts. It never silently switches billing modes or drops requests without returning a throttling error.
Q4. A developer wants a Lambda function to process records from a Kinesis Data Stream in the order they were written within each shard. Which statement about the event source mapping is correct?
  • A.  Kinesis pushes records directly to Lambda via a webhook rather than Lambda polling
  • B.  Lambda processes all shards and records completely out of order by design
  • C.  Records are processed in parallel across all shards with no ordering guarantee even within a shard
  • D.  Lambda polls the stream and processes records from a given shard in order, and a failed batch by default blocks further processing of that shard until it succeeds or expires
Show answer & explanation
✓ Answer: D. Lambda polls the stream and processes records from a given shard in order, and a failed batch by default blocks further processing of that shard until it succeeds or expires
The Lambda event source mapping polls Kinesis and preserves per-shard ordering; with default settings a failing batch retries and blocks that shard's checkpoint until it succeeds, expires, or is configured with a bisect/retry policy. Kinesis does not push via webhook - Lambda's poller pulls records.
Q5. Which Lambda deployment feature allows a developer to shift traffic gradually from an existing version to a new version, automatically rolling back on CloudWatch alarm triggers?
  • A.  Lambda Provisioned Concurrency
  • B.  AWS CodeDeploy traffic shifting with Lambda aliases (linear or canary deployment configurations)
  • C.  API Gateway usage plans
  • D.  Manually updating the $LATEST alias every few minutes based on dashboard observations
Show answer & explanation
✓ Answer: B. AWS CodeDeploy traffic shifting with Lambda aliases (linear or canary deployment configurations)
CodeDeploy integrates with Lambda aliases to perform canary or linear traffic shifting between versions, with automatic rollback if a configured CloudWatch alarm fires. Provisioned Concurrency addresses cold starts, not deployment safety, and usage plans control API throttling/quotas, not traffic shifting.
Test yourself
See the AWS Developer Associate (DVA-C02) page

More AWS Developer Associate (DVA-C02) topics