← AWS Developer Associate (DVA-C02)
Test yourself →

Development with AWS services & SDKs

Which SDK/tool for which job

AWS gives you several ways to talk to services: the AWS SDKs (Boto3 for Python, SDK for JavaScript, Java, .NET etc), the AWS CLI, and the AWS CloudShell. For DVA-C02 you need to know how the SDKs authenticate, retry, and handle errors - not just how to call an API.

Credential chain (default provider chain)

SDKs look for credentials in this order: environment variables, then the shared credentials/config file (~/.aws/credentials), then container credentials (ECS task role), then the EC2 instance metadata service (IMDS) for an instance profile role. Always prefer IAM roles over hard-coded access keys - never bake secrets into code or AMIs.

Retries and exponential backoff

AWS SDKs retry throttled or failed requests automatically using exponential backoff with jitter. This spreads out retries so many clients do not all hammer the service at the same instant. You can tune max retry attempts and backoff strategy in the SDK config (for example retryMode 'standard' or 'adaptive' in newer SDKs). Adaptive mode also throttles the client side send rate when it detects the service is struggling.

Idempotency

Many write APIs (like EC2 RunInstances or SQS SendMessage with a deduplication ID) accept a client token so a retried request does not create duplicate resources. Always pass an idempotency token for any operation you might retry.

Waiters and paginators

Waiters poll an API until a resource reaches a desired state (e.g. waiting for an EC2 instance to reach 'running'), saving you from writing your own polling loops. Paginators automatically handle APIs that return results in pages (using NextToken/Marker), looping through all pages for you.

X-Ray for tracing

The X-Ray SDK instruments your code to trace requests across microservices, showing latency and errors per segment/subsegment. Install the X-Ray daemon (or use the CloudWatch agent) to forward trace data; on Lambda, just enable Active Tracing - no daemon needed.

Exceptions and error handling

SDK calls throw service-specific exceptions (e.g. ThrottlingException, ProvisionedThroughputExceededException for DynamoDB). Catch these and apply backoff rather than failing immediately. HTTP 400s are client errors (fix the request), 500s are server errors (safe to retry).

Common exam traps

  • Do not hard-code AWS access keys in application code - use IAM roles.
  • The default retry behaviour is already exponential backoff with jitter - you rarely need to write your own.
  • IMDSv2 requires a session token via a PUT request first, then a GET with that token header - this closes off SSRF vulnerabilities that affected IMDSv1.
  • CLI and SDKs share the same underlying credential chain and config files.
  • The default credential provider chain order is: env vars, shared config/credentials file, container role, then EC2 instance metadata (IMDS) role
  • AWS SDKs use exponential backoff with jitter for automatic retries on throttled/failed requests
  • IMDSv2 requires a PUT request for a session token before GET requests - mitigates SSRF attacks that affected IMDSv1
  • Idempotency tokens (client tokens) prevent duplicate resource creation when retrying write API calls
  • Waiters poll an API until a resource reaches a target state, removing the need for manual polling loops
  • Paginators automatically iterate through multi-page API responses using NextToken or Marker
  • SDK retry mode can be set to legacy, standard, or adaptive - adaptive also throttles client-side send rate
  • X-Ray Active Tracing on Lambda needs no daemon - just enable it in function configuration
  • Never hard-code AWS access keys in application code or commit them to source control - use IAM roles instead
  • ThrottlingException and similar service-specific exceptions should trigger backoff-and-retry logic, not immediate failure
  • HTTP 4xx errors from an AWS API mean a client-side problem (fix the request); 5xx means a server-side problem (safe to retry)
  • The AWS CLI and all AWS SDKs share the same underlying credential chain and configuration files
What is the order of the default AWS credential provider chain?
Environment variables, then shared credentials/config file, then container role (ECS), then EC2 instance metadata (IMDS) role
tap to reveal
What retry strategy do AWS SDKs use by default?
Exponential backoff with jitter, to avoid many clients retrying at exactly the same moment
tap to reveal
What problem does IMDSv2 fix compared to IMDSv1?
It requires a PUT request for a session token before any GET, closing off SSRF-based credential theft
tap to reveal
What is an idempotency/client token used for?
Ensures a retried write API call does not create a duplicate resource
tap to reveal
What does a Waiter do in an AWS SDK?
Polls an API automatically until a resource reaches a desired state, e.g. waiting for an EC2 instance to be running
tap to reveal
What does a Paginator do?
Automatically loops through all pages of a multi-page API response using NextToken or Marker
tap to reveal
What are the three SDK retry modes?
Legacy, standard, and adaptive - adaptive also throttles the client send rate based on service health
tap to reveal
How do you enable X-Ray tracing on a Lambda function?
Turn on Active Tracing in the function configuration - no X-Ray daemon needed on Lambda
tap to reveal
Why should you avoid hard-coding AWS access keys in code?
It is a security risk - use IAM roles (instance profile, task role, or Lambda execution role) instead
tap to reveal
What does a ThrottlingException from DynamoDB mean and how should your code respond?
The request rate exceeded capacity; the SDK should retry with exponential backoff rather than failing immediately
tap to reveal
What is the difference between a 4xx and 5xx error from an AWS API?
4xx is a client-side error (fix your request); 5xx is a server-side error and generally safe to retry
tap to reveal
Do the AWS CLI and AWS SDKs use separate credential systems?
No - they share the same default credential provider chain and configuration files
tap to reveal
What AWS component do you install to forward X-Ray trace data from EC2/on-premises?
The X-Ray daemon (or the CloudWatch agent), which forwards segments to the X-Ray service
tap to reveal

Serverless (Lambda, API Gateway, DynamoDB)

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.

  • Lambda max execution timeout is 15 minutes (900 seconds); default is 3 seconds.
  • Lambda memory ranges from 128 MB to 10,240 MB in 1 MB increments; CPU scales with memory.
  • Lambda deployment zip limit is 50 MB compressed, 250 MB uncompressed (including layers); container images up to 10 GB.
  • API Gateway has a hard 29-second maximum integration timeout, regardless of Lambda's own timeout.
  • API Gateway default throttle is 10,000 requests/second steady-state with a 5,000 burst limit, account-wide.
  • DynamoDB item size limit is 400 KB.
  • One DynamoDB RCU = one strongly consistent read (or two eventually consistent reads) of up to 4 KB/second.
  • One DynamoDB WCU = one write of up to 1 KB/second.
  • DynamoDB LSIs must be created at table creation and share the base table's partition key; GSIs can be added anytime with their own keys.
  • DAX provides microsecond-latency in-memory caching for DynamoDB reads, transparent to application code.
  • Lambda reserved concurrency caps a function's max concurrent executions; provisioned concurrency pre-warms environments to avoid cold starts.
  • DynamoDB Streams capture item-level changes and can invoke Lambda functions for event-driven processing.
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

Security (IAM, Cognito, KMS, Secrets Manager)

IAM: the foundations

IAM is global, not regional. Every request is evaluated as an explicit DENY beats an explicit ALLOW, which beats the default implicit DENY. New identities have no permissions until a policy grants them.

  • Users, groups and roles all attach policies (JSON documents).
  • Roles are the exam favourite: they grant temporary credentials via STS (AssumeRole), used for cross-account access, EC2/Lambda execution, and federation. No long-term keys involved.
  • Policy types: identity-based (attached to user/group/role), resource-based (attached to the resource, e.g. S3 bucket policy, allows cross-account without a role), and permissions boundaries (cap the maximum permissions an identity can have).
  • IAM access keys should be rotated regularly; the exam expects you to know root account keys should never be used day-to-day.

Cognito: user identity for apps

Cognito has two separate pools and mixing them up is the classic trap.

  • User Pools: sign-up/sign-in directory. Issues JWTs (ID, access, refresh tokens) after authentication. Supports MFA, hosted UI, social/SAML federation.
  • Identity Pools: exchange a token (from a User Pool, Google, Facebook, SAML) for temporary AWS credentials via STS, so the app can call AWS services directly.
  • Remember: User Pool = authentication (who are you), Identity Pool = authorization to AWS resources (what can you touch).
  • Access tokens from a User Pool expire (default 1 hour); refresh tokens default to 30 days.

KMS: encryption keys

KMS manages Customer Master Keys (CMKs, now called KMS keys) used to encrypt data, never the data itself directly for large payloads.

  • Envelope encryption is the pattern: KMS encrypts a data key, the data key encrypts your actual data (get this for any 'large file' question).
  • Symmetric CMKs are default and cannot be exported; asymmetric keys exist for sign/verify or encrypt/decrypt outside AWS.
  • Key policies (resource-based) control access to a CMK and always take precedence in the evaluation alongside IAM.
  • KMS API calls (Encrypt, Decrypt, GenerateDataKey) are logged to CloudTrail — good for audit questions.
  • Automatic key rotation is available for symmetric CMKs on a yearly cycle when enabled.

Secrets Manager vs Parameter Store

Both store config, but the exam tests the differences hard.

  • Secrets Manager: built-in automatic rotation (via Lambda), charges per secret per month plus API calls, native RDS/Redshift/DocumentDB rotation templates.
  • Systems Manager Parameter Store: free tier (standard parameters), no built-in rotation (you'd script it), supports plain strings, string lists, and SecureString (KMS-encrypted).
  • SecureString parameters need kms:Decrypt permission as well as ssm:GetParameter.
  • Common mistake: assuming Parameter Store rotates secrets automatically — it does not, you must build that yourself.

Common exam traps

  • Confusing resource policies (can grant cross-account access directly) with identity policies (cannot, by themselves, grant access to another account's resource).
  • Forgetting that STS temporary credentials are short-lived and must be refreshed, not cached forever.
  • Thinking Cognito Identity Pools handle sign-in UI — they don't, that's User Pools.
  • IAM is a global service, not tied to any single AWS region.
  • Explicit DENY always overrides explicit ALLOW, and both override the default implicit DENY.
  • IAM Roles provide temporary credentials via AWS STS, ideal for EC2/Lambda execution and cross-account access.
  • Cognito User Pools handle authentication and issue JWTs; Identity Pools exchange tokens for temporary AWS credentials.
  • Cognito User Pool access tokens default to a 1-hour expiry; refresh tokens default to 30 days.
  • KMS uses envelope encryption: a data key encrypts your data, and KMS encrypts that data key with a CMK.
  • Symmetric KMS keys support automatic annual rotation when enabled; they cannot be exported from KMS.
  • Secrets Manager supports automatic rotation via Lambda; Parameter Store does not rotate secrets automatically.
  • Parameter Store SecureString parameters are encrypted using KMS and need kms:Decrypt plus ssm:GetParameter permissions.
  • Resource-based policies (e.g. S3 bucket policies, KMS key policies) can grant cross-account access without assuming a role.
  • Secrets Manager charges per secret per month; Parameter Store standard parameters are free.
  • Permissions boundaries set the maximum permissions an IAM identity can ever have, regardless of attached policies.
Is IAM a global or regional AWS service?
Global — IAM is not scoped to a region.
tap to reveal
In IAM policy evaluation, what wins: explicit DENY, explicit ALLOW, or implicit DENY?
Explicit DENY always wins, then explicit ALLOW, then the default implicit DENY applies if nothing matches.
tap to reveal
What AWS service issues temporary credentials when an IAM Role is assumed?
AWS STS (Security Token Service), via the AssumeRole API.
tap to reveal
What is the key difference between a Cognito User Pool and an Identity Pool?
User Pool = authentication directory issuing JWTs; Identity Pool = exchanges tokens for temporary AWS credentials to access AWS resources.
tap to reveal
What is the default expiry for a Cognito User Pool access token?
1 hour by default.
tap to reveal
What is the default expiry for a Cognito User Pool refresh token?
30 days by default.
tap to reveal
What is envelope encryption in KMS?
KMS encrypts a data key; that data key is then used to encrypt the actual data, rather than KMS encrypting the data directly.
tap to reveal
Can a symmetric KMS CMK be exported outside of KMS?
No, symmetric KMS keys cannot be exported.
tap to reveal
Does Secrets Manager or Parameter Store offer built-in automatic secret rotation?
Secrets Manager, using a Lambda function; Parameter Store has no built-in rotation.
tap to reveal
What permission, besides ssm:GetParameter, is needed to read a SecureString parameter?
kms:Decrypt on the KMS key used to encrypt it.
tap to reveal
Which policy type can grant cross-account access without the requester assuming a role?
Resource-based policies, e.g. an S3 bucket policy or a KMS key policy.
tap to reveal
What does a permissions boundary do in IAM?
It sets the maximum permissions an identity can have, capping what any attached policies can grant.
tap to reveal
How often can automatic key rotation occur for a symmetric KMS CMK?
Yearly, when automatic rotation is enabled.
tap to reveal
Which is free: Secrets Manager or Parameter Store standard parameters?
Parameter Store standard parameters are free; Secrets Manager charges per secret per month.
tap to reveal

Deployment (CI/CD, CodePipeline, Elastic Beanstalk)

CI/CD on AWS

CI/CD pipelines automate build, test and release so code ships safely and often. The exam leans on three services working together: CodeCommit (or GitHub) for source, CodeBuild for build/test, CodeDeploy for release, all orchestrated by CodePipeline.

CodePipeline basics

  • A pipeline is made of stages, and stages contain actions (source, build, test, deploy, approval).
  • Stages run sequentially; actions within a stage can run in parallel.
  • Add a Manual Approval action to pause a pipeline until a human approves - useful before a production deploy.
  • Pipeline changes trigger automatically on a source change (via CloudWatch Events/EventBridge for CodeCommit, or webhooks for GitHub) - it is event-driven, not purely polling by default.
  • Artifacts pass between stages via an S3 bucket - CodePipeline needs an S3 artifact store.

CodeBuild

  • Defined by a buildspec.yml with phases: install, pre_build, build, post_build.
  • Runs in managed, ephemeral containers - you pay per build minute, no servers to manage.
  • Can output build artifacts and logs to CloudWatch Logs.

CodeDeploy deployment types

  • EC2/On-Premises: uses an AppSpec file (appspec.yml) with hooks like BeforeInstall, ApplicationStop, AfterInstall, ApplicationStart, ValidateService.
  • Lambda: deployment configs control traffic shifting - Canary (small % first, then rest after a wait), Linear (steady % increases at intervals), All-at-once.
  • ECS: supports Blue/Green deployments via CodeDeploy, shifting traffic between task sets using an ALB.
  • CodeDeploy can auto-rollback on CloudWatch alarm breach or deployment failure.

Elastic Beanstalk

  • PaaS: upload code (or a Docker image), Beanstalk provisions EC2, ASG, ELB, and RDS (optional) for you - you don't manage the underlying resources directly.
  • Deployment policies: All at once (fastest, downtime), Rolling (batches, reduced capacity), Rolling with additional batch (no capacity loss, launches extra batch first), Immutable (new ASG entirely, safest, slowest, easy rollback), Traffic Splitting (canary-style, % of traffic to new version).
  • Configuration lives in .ebextensions/*.config files (YAML/JSON) inside your app bundle, applied in alphabetical order.
  • Environments: separate Web Server (fronts an ALB) vs Worker (polls an SQS queue) environment tiers.
  • Beanstalk is NOT for zero-downtime by default with All-at-once - pick Immutable or Traffic Splitting when zero downtime matters.

Common exam traps

  • CodeDeploy needs an IAM service role AND an appspec.yml at the root of the deployment bundle - a missing appspec.yml fails deployment.
  • Blue/Green on EC2 needs an ASG and ELB; on Lambda it's really traffic shifting between versions/aliases, not separate EC2 fleets.
  • Beanstalk swap environment URLs (CNAME swap) gives a near-zero-downtime blue/green style cutover between two full environments.
  • CodePipeline stages run sequentially, but actions inside a stage can run in parallel.
  • CodeBuild's buildspec.yml has four phases: install, pre_build, build, post_build.
  • CodeDeploy for EC2/On-Premises uses appspec.yml with hooks: BeforeInstall, ApplicationStop, AfterInstall, ApplicationStart, ValidateService.
  • Lambda deployment configs: Canary (small % then rest after a wait), Linear (steady increases), All-at-once (100% immediately).
  • Elastic Beanstalk deployment policies: All at once, Rolling, Rolling with additional batch, Immutable, Traffic Splitting.
  • Immutable deployments launch a brand-new ASG/instance set for the safest, easiest-rollback deploy, but are the slowest.
  • Elastic Beanstalk configuration files (.ebextensions) are applied in alphabetical order from the app bundle root.
  • Elastic Beanstalk has two environment tiers: Web Server (behind an ALB) and Worker (polls an SQS queue).
  • CodePipeline requires an S3 bucket as its artifact store to pass files between stages.
  • A Manual Approval action in CodePipeline pauses the pipeline until an authorised user approves or rejects it.
  • CodeDeploy can automatically roll back a deployment on CloudWatch alarm breach or deployment failure.
  • Elastic Beanstalk CNAME swap lets you cut traffic between two full environments for a near-zero-downtime blue/green release.
What are the four phases of a CodeBuild buildspec.yml?
install, pre_build, build, post_build
tap to reveal
Which file does CodeDeploy require for EC2/On-Premises deployments, and where must it sit?
appspec.yml, at the root of the deployment bundle
tap to reveal
Name the five hooks available in an EC2 CodeDeploy appspec.yml lifecycle.
BeforeInstall, ApplicationStop, AfterInstall, ApplicationStart, ValidateService
tap to reveal
What are the three Lambda CodeDeploy traffic-shifting deployment types?
Canary, Linear, All-at-once
tap to reveal
List the five Elastic Beanstalk deployment policies.
All at once, Rolling, Rolling with additional batch, Immutable, Traffic Splitting
tap to reveal
Which Elastic Beanstalk deployment policy is safest and easiest to roll back, but slowest?
Immutable - it launches a whole new ASG before switching traffic
tap to reveal
What does CodePipeline need to pass artifacts between stages?
An S3 bucket configured as the artifact store
tap to reveal
How do you pause a CodePipeline pipeline for human sign-off before deploying to production?
Add a Manual Approval action to a stage
tap to reveal
What triggers a CodePipeline run when CodeCommit is the source?
An EventBridge/CloudWatch Events rule on the repository change (event-driven, not just polling)
tap to reveal
In what order are .ebextensions config files applied in Elastic Beanstalk?
Alphabetical order, from the root of the application bundle
tap to reveal
What are the two Elastic Beanstalk environment tiers and what fronts each?
Web Server tier (fronted by an ALB) and Worker tier (polls an SQS queue)
tap to reveal
How does Elastic Beanstalk achieve a near-zero-downtime blue/green cutover?
By swapping CNAMEs between two separate, fully deployed environments
tap to reveal
What triggers an automatic CodeDeploy rollback?
A CloudWatch alarm breach or a deployment failure
tap to reveal
On ECS, how does CodeDeploy perform Blue/Green deployments?
It shifts ALB traffic between two ECS task sets
tap to reveal

Monitoring & troubleshooting (CloudWatch, X-Ray)

CloudWatch: metrics, alarms and logs

CloudWatch is the default monitoring backbone for AWS. Every service pushes metrics automatically at 5-minute intervals (standard resolution). Enable Detailed Monitoring on EC2 to get 1-minute granularity - this costs extra and is NOT on by default.

Custom metrics are published with PutMetricData. You can go below 1 minute using High-Resolution metrics (down to 1 second), but this needs the StorageResolution parameter set to 1.

Metric retention matters for the exam

  • Data at 1-second resolution is kept for 3 hours
  • 1-minute data points are kept for 15 days
  • 5-minute data points are kept for 63 days
  • 1-hour data points are kept for 15 months

CloudWatch automatically 'rolls up' older data to coarser resolution - it does not delete it early.

Alarms

An alarm watches a single metric (or a metric math expression) over a number of evaluation periods and moves between OK, ALARM and INSUFFICIENT_DATA states. Composite alarms combine multiple alarms with AND/OR logic. Alarms can trigger SNS notifications, Auto Scaling actions, or EC2 actions (stop, terminate, reboot, recover).

Logs

CloudWatch Logs organises data into Log Groups then Log Streams. Set retention per log group (default is Never Expire, which quietly costs money forever - a classic gotcha). Use Metric Filters to turn log patterns (like ERROR strings) into numeric CloudWatch metrics you can alarm on. Subscription Filters stream logs in near real time to Lambda, Kinesis or OpenSearch for further processing. CloudWatch Logs Insights lets you query log data with its own query language without building a pipeline first.

CloudWatch Events / EventBridge

EventBridge (the evolution of CloudWatch Events) reacts to AWS service state changes or scheduled rules (cron/rate expressions) and routes them to targets like Lambda or SNS.

X-Ray for distributed tracing

X-Ray traces a request as it moves through microservices, showing a service map and latency breakdown per hop (called segments and subsegments). You must install the X-Ray daemon (or use the built-in agent on Lambda) and instrument your code with the X-Ray SDK. Annotations are indexed key-value pairs you can filter traces by; metadata is not indexed and is for extra context only. Sampling defaults to recording the first request each second plus 5% of additional requests - tune this with sampling rules to control cost.

Common exam traps

  • Detailed Monitoring (1-min) is opt-in and chargeable, not default
  • Metric filters count matching log LINES, they don't parse arbitrary JSON structure without a defined pattern
  • X-Ray needs IAM permissions (xray:PutTraceSegments) even inside Lambda
  • Annotations are searchable, metadata is not - mixing these up is a favourite distractor
  • Standard CloudWatch metrics arrive every 5 minutes; Detailed Monitoring on EC2 gives 1-minute data and must be enabled manually
  • High-resolution custom metrics can be published at 1-second intervals using StorageResolution=1 in PutMetricData
  • 1-second metric data is retained 3 hours, 1-minute data 15 days, 5-minute data 63 days, 1-hour data 15 months
  • CloudWatch Logs log groups default to Never Expire retention unless you set a retention policy explicitly
  • Metric Filters convert log patterns into CloudWatch metrics that can then trigger alarms
  • Subscription Filters stream CloudWatch Logs in near real time to Lambda, Kinesis Streams/Firehose or OpenSearch
  • Composite Alarms combine multiple existing alarms using AND/OR logic to reduce alert noise
  • CloudWatch alarm states are OK, ALARM and INSUFFICIENT_DATA
  • X-Ray requires the xray:PutTraceSegments IAM permission plus either the X-Ray daemon or SDK instrumentation
  • X-Ray default sampling rule records the first request per second plus 5% of extra requests, adjustable via sampling rules
  • X-Ray Annotations are indexed and searchable/filterable; X-Ray Metadata is not indexed, for context only
  • EventBridge (formerly CloudWatch Events) routes AWS state-change events or scheduled cron/rate rules to targets like Lambda or SNS
What is the default CloudWatch metric resolution for most AWS services?
5 minutes (standard resolution); Detailed Monitoring gives 1-minute but must be enabled and costs extra
tap to reveal
How do you publish a custom metric at sub-minute resolution?
Call PutMetricData with StorageResolution set to 1, giving 1-second high-resolution metrics
tap to reveal
How long is 1-minute resolution CloudWatch metric data retained?
15 days
tap to reveal
How long is 5-minute resolution CloudWatch metric data retained?
63 days
tap to reveal
How long is 1-hour resolution CloudWatch metric data retained?
15 months
tap to reveal
What is the default log group retention period in CloudWatch Logs?
Never Expire - you must set a retention policy explicitly or logs (and cost) accumulate forever
tap to reveal
What turns a CloudWatch Logs pattern into an alarmable numeric metric?
A Metric Filter
tap to reveal
What streams CloudWatch Logs data to Lambda, Kinesis or OpenSearch in near real time?
A Subscription Filter
tap to reveal
What combines multiple CloudWatch alarms with AND/OR logic?
A Composite Alarm
tap to reveal
What are the three states a CloudWatch alarm can be in?
OK, ALARM, and INSUFFICIENT_DATA
tap to reveal
What component collects trace data on an EC2 instance for X-Ray?
The X-Ray daemon (on Lambda, tracing is built in without needing a separate daemon)
tap to reveal
What is X-Ray's default sampling behaviour?
Records the first request each second plus 5% of any additional requests, and this is configurable via sampling rules
tap to reveal
What is the difference between X-Ray Annotations and Metadata?
Annotations are indexed key-value pairs you can search/filter traces by; Metadata is not indexed and is for extra context only
tap to reveal
What IAM permission does X-Ray tracing require to send trace data?
xray:PutTraceSegments
tap to reveal
What service replaced and expanded CloudWatch Events for event-driven routing?
Amazon EventBridge, which routes AWS state changes or scheduled cron/rate rules to targets like Lambda or SNS
tap to reveal

Refactoring & optimisation

Why this topic matters

DVA-C02 tests whether you can spot performance and cost problems in code and infrastructure, then fix them using the right AWS feature rather than brute-force scaling. Exam questions usually describe a slow, expensive, or throttled app and ask what change fixes it cheapest/fastest.

Lambda optimisation

  • Increasing memory also increases proportional CPU and network - a common fix for slow functions is simply raising memory, not just code changes.
  • Provisioned Concurrency removes cold starts by keeping execution environments warm - use for latency-sensitive APIs.
  • Keep the handler lean: initialise SDK clients and DB connections OUTSIDE the handler function so they persist across warm invocations.
  • Lambda SnapStart (Java, and now other runtimes) caches a snapshot of an initialised execution environment to cut cold-start time drastically.
  • Use environment variables and Lambda layers to share code/dependencies instead of duplicating in every deployment package - smaller packages deploy and cold-start faster.

DynamoDB optimisation

  • Design partition keys for even distribution - hot partitions throttle throughput even under provisioned capacity.
  • Use DynamoDB Accelerator (DAX) for microsecond read caching in read-heavy workloads.
  • Switch to on-demand capacity mode for unpredictable traffic; use provisioned with auto scaling for steady, predictable traffic - cheaper at scale.
  • Batch operations (BatchGetItem, BatchWriteItem) reduce round trips versus single-item calls.
  • Use sparse indexes and projections to avoid pulling unnecessary attributes.

Caching layers

  • ElastiCache (Redis/Memcached) offloads repeated reads from RDS/DynamoDB - biggest win for read-heavy relational workloads.
  • CloudFront caches at edge locations, cutting origin load and latency for static and semi-static content; use cache behaviours and TTLs per path pattern.
  • API Gateway has its own response caching (per stage, TTL configurable 0-3600s) - reduces backend Lambda/API invocations for repeated identical requests.

Code-level and messaging optimisation

  • Use SQS to decouple and buffer bursty workloads so downstream services process at their own pace - prevents overload rather than requiring bigger instances.
  • Use asynchronous invocation or Step Functions for long-running workflows instead of synchronous blocking calls.
  • X-Ray traces reveal exactly which downstream call or segment is the bottleneck - always the first tool the exam expects you to reach for when diagnosing 'why is this slow'.
  • CloudWatch Lambda Insights and Application Signals give system-level metrics (memory used vs allocated, cold start counts) to right-size functions.

Common mistakes

  • Assuming more compute always fixes it - often it is a hot partition key or missing cache, not raw power.
  • Forgetting SDK client re-use across invocations, causing needless re-initialisation cost on every warm call.
  • Ignoring API Gateway/CloudFront caching and hitting the backend for identical repeated GET requests.
  • Using on-demand DynamoDB for steady, predictable heavy traffic where provisioned + auto scaling is cheaper.
  • Initialise SDK clients and DB connections OUTSIDE the Lambda handler so they persist across warm invocations
  • Lambda Provisioned Concurrency keeps execution environments warm to eliminate cold starts for latency-sensitive workloads
  • Lambda SnapStart caches an initialised execution environment snapshot to drastically cut cold-start times
  • Increasing Lambda memory proportionally increases allocated CPU and network bandwidth too
  • DAX (DynamoDB Accelerator) provides microsecond in-memory read caching in front of DynamoDB
  • DynamoDB on-demand mode suits unpredictable traffic; provisioned + auto scaling is cheaper for steady, predictable traffic
  • API Gateway response caching is configurable per stage with a TTL from 0 to 3600 seconds
  • SQS decouples bursty producers from consumers so downstream services are not overwhelmed
  • X-Ray tracing is the go-to tool for pinpointing which segment or downstream call is causing latency
  • Hot partition keys throttle DynamoDB throughput regardless of provisioned capacity - design keys for even distribution
  • CloudFront caches content at edge locations to reduce origin load and cut latency for repeat requests
  • BatchGetItem and BatchWriteItem reduce DynamoDB round trips compared with single-item calls
What is the single most common fix for a slow Lambda function on the exam?
Increase the memory allocation - CPU and network scale proportionally with memory
tap to reveal
How do you eliminate Lambda cold starts for a latency-sensitive API?
Enable Provisioned Concurrency
tap to reveal
What Lambda feature caches an initialised execution environment to speed up cold starts?
Lambda SnapStart
tap to reveal
Where should you initialise a DynamoDB or S3 SDK client in a Lambda function?
Outside the handler, so it is reused across warm invocations instead of recreated each time
tap to reveal
What DynamoDB feature gives microsecond read latency via in-memory caching?
DAX - DynamoDB Accelerator
tap to reveal
When should you choose DynamoDB on-demand capacity over provisioned?
When traffic is unpredictable or spiky; provisioned with auto scaling is cheaper for steady predictable load
tap to reveal
What causes DynamoDB throttling even when provisioned capacity looks sufficient?
A hot partition key - uneven key distribution concentrates traffic on one partition
tap to reveal
What is the TTL range for API Gateway stage-level response caching?
0 to 3600 seconds, configurable per stage
tap to reveal
What AWS service decouples a bursty producer from a slower downstream consumer?
SQS - it buffers messages so consumers process at their own pace
tap to reveal
What is the first tool to reach for when diagnosing why a distributed request is slow?
AWS X-Ray - it traces the request across services to isolate the bottleneck segment
tap to reveal
How do you cut repeated identical GET requests hitting your backend origin?
Use CloudFront edge caching or API Gateway response caching with an appropriate TTL
tap to reveal
What DynamoDB API calls reduce round trips for multiple items?
BatchGetItem and BatchWriteItem
tap to reveal
What is a common Lambda packaging mistake that slows cold starts?
Bundling large, unused dependencies instead of trimming the package or using Lambda layers for shared code
tap to reveal
Why use Step Functions or async invocation instead of synchronous Lambda calls for long workflows?
It avoids blocking callers and timeouts on long-running processes, letting each step run and retry independently
tap to reveal