AWS Developer Associate (DVA-C02) β€” Exam-Aligned Study Guide

Structured by Official Exam Guide Domains and Tasks Reference: AWS DVA-C02 Exam Guide PDF Last updated: March 2026


Exam Blueprint

DomainWeightQuestions (~65 total)
1. Development with AWS Services32%~21
2. Security26%~17
3. Deployment24%~16
4. Troubleshooting and Optimization18%~11

DOMAIN 1 β€” Development with AWS Services (32%)


Task 1.1: Develop Code for Applications Hosted on AWS

1.1.1 Architectural Patterns

  Loosely Coupled                         Tightly Coupled
  β”Œβ”€β”€β”€β”€β”€β”  SQS  β”Œβ”€β”€β”€β”€β”€β”                 β”Œβ”€β”€β”€β”€β”€β”β”€β”€β”€β–Άβ”Œβ”€β”€β”€β”€β”€β”
  β”‚ Svc │──────▢│ Svc β”‚  Resilient       β”‚ Svc β”‚    β”‚ Svc β”‚  Fragile
  β”‚  A  β”‚       β”‚  B  β”‚                  β”‚  A  │◀───│  B  β”‚
  β””β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”˜                 β””β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”˜

  Fan-out Pattern:                Event-Driven:
  SNS ──▢ SQS-1 ──▢ Svc-A        S3 Event ──▢ Lambda
      ──▢ SQS-2 ──▢ Svc-B        DDB Stream ──▢ Lambda
      ──▢ SQS-3 ──▢ Svc-C        EventBridge ──▢ Step Functions

Service Selection for Decoupling:

PatternServiceWhen to Use
Queue-basedSQSPoint-to-point, async processing
Pub/SubSNSOne-to-many broadcast
Fan-outSNS + SQSBroadcast + independent parallel processing
Event busEventBridgeCross-account, SaaS integration, rule-based
StreamingKinesis Data StreamsReal-time, ordered, high-volume data ingestion
OrchestrationStep FunctionsComplex multi-step workflows with state
ChoreographyEventBridgeLoosely coupled event-driven microservices

1.1.2 AWS SDK and API Essentials

Retry and Exponential Backoff:

  • All AWS SDKs implement automatic retries with exponential backoff
  • ThrottlingException, ProvisionedThroughputExceededException trigger auto-retry
  • Custom formula: base * 2^attempt with jitter (add randomness to avoid thundering herd)
  • Always cap maximum backoff to prevent infinite waits

Pagination:

  • Most List* / Describe* APIs return paginated results
  • Use NextToken / Marker to fetch subsequent pages
  • SDKs provide built-in paginators (e.g., .pages() in Python boto3)

Waiters:

  • SDK utility to poll until a resource reaches a desired state
  • Example: ec2.get_waiter('instance_running').wait(InstanceIds=[...])

Idempotency:

  • Use ClientToken / IdempotencyToken to prevent duplicate operations
  • SQS FIFO: MessageDeduplicationId provides 5-minute dedup window

1.1.3 Amazon API Gateway

Endpoint Types:

TypeDescriptionUse Case
Edge-optimizedRouted through CloudFront edge locationsGlobal clients (default)
RegionalServed from the API regionSame-region clients, custom CDN
PrivateAccessible only from within a VPCInternal microservices

Integration Types:

IntegrationRequest TransformResponse TransformNotes
Lambda ProxyNo (raw pass)No (Lambda formats)Lambda MUST return {statusCode, headers, body}
Lambda CustomMapping templateMapping templateUse for SOAP-to-REST, XML-to-JSON
HTTP ProxyNoNoPass-through to HTTP endpoint
HTTP CustomMapping templateMapping templateTransform before/after HTTP backend
AWS ServiceMapping templateMapping templateDirect integration (SQS, DynamoDB, S3)

Stages and Stage Variables:

  • Deploy to named stages: /dev, /staging, /prod
  • Stage variables act as environment variables for API Gateway
  • Reference Lambda alias via stage variable: ${stageVariables.lambdaAlias}
  • Canary deployments on stages: route percentage of traffic to canary

Caching:

  • Enable per stage; TTL 0-3600s (default 300s)
  • Invalidate: Cache-Control: max-age=0 header (requires execute-api:InvalidateCache)
  • Metrics: CacheHitCount, CacheMissCount (only visible when caching enabled)

Throttling:

  • Account-level: 10,000 requests/second (soft limit)
  • Stage/method-level throttling via Usage Plans
  • API Keys for identification (NOT authentication), paired with Usage Plans
  • Returns 429 Too Many Requests when throttled

CORS:

  • Lambda Proxy: Return CORS headers FROM the Lambda function itself
  • Lambda Custom: Configure CORS in API Gateway console
  • Required headers: Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers

Error Codes:

CodeMeaningRoot Cause
400Bad RequestMalformed request syntax
403ForbiddenWAF blocked, IAM denied, resource policy denied
429Too Many RequestsThrottle limit exceeded
502Bad GatewayLambda returned invalid response format
503Service UnavailableTemporary backend issue
504Gateway TimeoutBackend exceeded 29-second integration timeout

1.1.4 Messaging and Event Services

Amazon SQS:

FeatureStandard QueueFIFO Queue
ThroughputUnlimited300 TPS (3,000 with batching)
DeliveryAt-least-onceExactly-once
OrderingBest-effortStrict FIFO per Message Group ID
DeduplicationNoneContent-based or MessageDeduplicationId
Queue nameAnyMust end with .fifo
Retention1 min - 14 days (default 4)Same
Max message size256 KB256 KB
Visibility timeout0s - 12h (default 30s)Same
  • Visibility Timeout: Set >= max processing time; for Lambda, set >= 6x Lambda timeout
  • Dead-Letter Queue (DLQ): After maxReceiveCount failures, message sent to DLQ
  • Long Polling: WaitTimeSeconds > 0 (max 20s) reduces empty responses and cost
  • Short Polling: Returns immediately, may return empty, more API calls
  • Extended Client Library (Java only): For messages > 256 KB (up to 2 GB via S3)

Amazon SNS:

  • Pub/Sub: topic to subscribers (Lambda, SQS, HTTP/S, email, SMS)
  • Message Filtering: Subscription filter policy so subscribers get only matching messages
  • Fan-out: SNS to multiple SQS queues for parallel independent processing
  • FIFO Topics: Pair with SQS FIFO for ordered fan-out
  • Message attributes: Key-value metadata attached to messages

Amazon EventBridge:

  • Serverless event bus for application events
  • Rules: Match event patterns and route to targets (Lambda, SQS, Step Functions)
  • Schema Registry: Auto-discover and version event schemas
  • Archive and Replay: Store events and replay them for debugging/recovery
  • Cross-account: Send/receive events across AWS accounts
  • Scheduler: Cron and rate-based scheduling (replaces CloudWatch Events)

Amazon Kinesis Data Streams:

FeatureDetail
Retention24 hours default, max 365 days
OrderingPer shard (by partition key)
ConsumersStandard (shared) or Enhanced (dedicated)
Throughput per shard1 MB/s in, 2 MB/s out (standard)
Enhanced fan-out2 MB/s per consumer per shard
ReshardingSplit hot shards, merge cold shards
  • PutRecord + SequenceNumberForOrdering = strict order within shard
  • PutRecords (batch) does NOT guarantee cross-record order
  • ProvisionedThroughputExceededException use exponential backoff or increase shards

1.1.5 AWS Step Functions

Workflow Types:

FeatureStandardExpress
DurationUp to 1 yearUp to 5 minutes
Execution modelExactly-onceAt-least-once (async) or sync
PricingPer state transitionPer execution + duration + memory
HistoryFull (25,000 events max)Sent to CloudWatch Logs
Use caseLong-running, auditableHigh-volume, short-lived (IoT)

State Types:

StatePurpose
TaskDo work (Lambda, ECS, Batch, DynamoDB, SNS, SQS)
ChoiceConditional branching (if/else)
WaitDelay by seconds or until a timestamp
ParallelRun branches concurrently
MapIterate over an array (dynamic parallelism)
PassPass-through / inject fixed data (debugging)
SucceedTerminal success state
FailTerminal failure state (no retry from Fail)

Input/Output Processing:

  Raw Input
      |
  InputPath ---- Filter what the state sees (e.g., "$.order")
      |
  Parameters --- Reshape input, add static values
      |
  [  STATE  ] -- Does work, produces RESULT
      |
  ResultSelector -- Filter/transform raw result
      |
  ResultPath ----- WHERE to place result relative to input
      |               "$.taskResult" = input.taskResult = result
      |               "$"            = result REPLACES entire input
      |               null           = result DISCARDED, input unchanged
  OutputPath ----- Final filter for next state
      |
  Output to Next State

Exam key: ResultPath is the one that COMBINES input + result.

Error Handling:

  • Retry: ErrorEquals, IntervalSeconds, MaxAttempts, BackoffRate
  • Catch: ErrorEquals, Next (fallback state), ResultPath (preserve error info)
  • Flow: Error then Retry (up to MaxAttempts) then Catch then Next state
  • Predefined errors: States.ALL, States.Timeout, States.TaskFailed, States.Permissions
  • Retry and Catch defined in state machine JSON, NOT application code

Task 1.2: Develop Code for AWS Lambda

1.2.1 Lambda Invocation Types

TypeBehaviorError HandlingSources
SynchronousCaller waits for responseCaller handles errorsAPI Gateway, ALB, SDK Invoke()
AsynchronousReturns 202 immediately, queues internallyAuto-retry 2x, then DLQ/destinationS3, SNS, EventBridge, CloudFormation
Poll-based (ESM)Lambda service polls sourceDLQ on source queue (not Lambda)SQS, Kinesis, DynamoDB Streams

Event Source Mapping (ESM) Details:

SourceBatch SizeFailure Handling
SQS1-10ReportBatchItemFailures for partial batch retry
KinesisUp to 10,000BisectBatchOnFunctionError, on-failure destination
DynamoDB StreamsUp to 10,000BisectBatchOnFunctionError, on-failure destination
  • SQS: DLQ configured on the SQS queue, NOT on Lambda
  • Kinesis/DDB: MaximumRetryAttempts, MaximumRecordAgeInSeconds
  • Parallelization factor: Process multiple batches per shard concurrently

1.2.2 Concurrency Model

  Account Concurrency Pool (Default: 1,000)
  +-----------------------------------------+
  |  Reserved (Fn-A): 400  (guaranteed)     |
  |  Reserved (Fn-B): 200  (guaranteed)     |
  |  Unreserved Pool: 400  (shared by rest) |
  |  AWS keeps minimum 100 unreserved!      |
  +-----------------------------------------+

  Formula: concurrent_executions = invocations/sec x avg_duration_sec
Concurrency TypeBehavior
UnreservedShared pool across all functions (default)
ReservedGuarantees AND caps capacity for a function
ProvisionedPre-initializes execution environments (eliminates cold starts)
  • Setting reserved concurrency to 0 = function completely disabled
  • Throttled: synchronous returns 429; async auto-retries then DLQ

1.2.3 Execution Lifecycle

  COLD START:  Download code -> Start runtime -> Run INIT code -> Run handler
  WARM START:  INIT skipped -> Run handler directly

  Optimization: Put expensive setup OUTSIDE the handler
  - DB connections, SDK clients, cached data persist across warm invocations
  - /tmp directory persists too (512 MB free, up to 10 GB)

1.2.4 Lambda Configuration Limits

SettingDetail
Memory128 MB - 10,240 MB (CPU scales proportionally)
TimeoutMax 15 minutes (900 seconds)
Ephemeral storage/tmp: 512 MB (free) up to 10 GB
Deployment package50 MB zipped, 250 MB unzipped (incl. layers)
LayersMax 5 per function; extract to /opt/
Env variablesMax 4 KB total size
vCPUCannot set directly (controlled by memory setting)
1 full vCPUAt 1,769 MB memory

1.2.5 Lambda Networking (VPC)

  DEFAULT (no VPC):  Lambda --> Internet --> AWS APIs  (Private RDS not accessible)
  WITH VPC CONFIG:   Lambda --ENI--> Private Subnet --> RDS
                     For internet: Lambda --> NAT GW --> IGW --> Internet
                     For AWS APIs: Use VPC Endpoints (no NAT GW needed)
  • Lambda creates ENIs (Elastic Network Interfaces), NOT Elastic IPs
  • VPC config adds cold start latency; only use when needed

1.2.6 Lambda Layers and Deployment

  • Layers: shared code/libraries across functions (extract to /opt/)
  • Max 5 layers per function; 250 MB total unzipped (function + all layers)
  • CloudFormation ZipFile: Inline source code (Node.js and Python only); NOT a zip file path

1.2.7 Destinations vs DLQ

FeatureDestinationsDLQ (Dead Letter Queue)
Event typesSuccess AND failureFailure only
TargetsSQS, SNS, Lambda, EventBridgeSQS or SNS only
ScopeAsync invocations onlyAsync invocations only
RecommendationPreferred (more flexible)Legacy (still supported)

1.2.8 Aliases and Versions

  • Version: Immutable snapshot of function code + config
  • Alias: Pointer to a version (e.g., PROD points to v5)
  • Weighted alias: Route traffic between two versions (canary/linear)
  • $LATEST: Mutable, always latest code; cannot be referenced by alias weights
  • CodeDeploy integrates with aliases for automated traffic shifting

1.2.9 Lambda at the Edge

FeatureCloudFront FunctionsLambda@Edge
RuntimeJavaScript onlyNode.js, Python
Execution location218+ edge locationsRegional edge caches
Max durationLess than 1 ms5s (viewer), 30s (origin)
Max memory2 MB128-3,008 MB
Network/file accessNoYes
Use caseHeader manipulation, URL rewritesAuth, A/B testing, origin selection

1.2.10 Lambda Function URLs

A dedicated HTTPS endpoint for a Lambda function β€” no API Gateway required.

Auth Types:

Auth TypeWho Can InvokeUse Case
AWS_IAMOnly callers with valid IAM credentialsInternal services, cross-account invocations
NONEAnyone on the internet (public)Webhooks, third-party callbacks, public APIs
  • Function URL format: https://<url-id>.lambda-url.<region>.on.aws
  • Supports streaming response (response payload streamed as it’s generated)
  • CORS configurable directly on the Function URL (no API Gateway needed)
  • Resource-based policy controls access (even with NONE auth, you can restrict by IP/account)

Lambda Function URL vs API Gateway:

FeatureLambda Function URLAPI Gateway
CostFree (pay only for Lambda)Per-request + data transfer charges
Setup effortMinimal (one click / one line)More setup (stages, methods, resources)
Auth optionsAWS_IAM or NONEIAM, Cognito, Lambda Authorizer, API Keys
CachingNoYes (built-in)
Throttling / Usage PlansNoYes
Request/response transformNoYes (mapping templates)
Custom domainNo (use CloudFront in front)Yes (native custom domains)
WAF integrationNoYes
Webhook from third-partyBest choice (simplest)Works but more overhead

Webhook Pattern (exam favorite):

  Third-Party Platform (e.g., Stripe, GitHub)
      |
      | HTTPS POST with signature in headers
      | (platform signs with a secret key)
      v
  Lambda Function URL (AuthType: NONE)
      |
      | Step 1: Extract signature from headers
      | Step 2: Recompute signature using shared secret
      | Step 3: Compare signatures
      |    Match --> Execute domain logic
      |    No match --> Return 403 (reject)
      |
  (Custom validation IN the Lambda code itself)

Exam Trap β€” Function URL vs API Gateway for Webhooks:

Question PatternAnswer
Third-party webhook + public HTTPS + least effortLambda Function URL (NONE) + custom validation
Webhook + signature in headers + validate before processingLambda Function URL (NONE) + validate in code
Third-party webhook + API Gateway + Lambda AuthorizerWorks but NOT least effort (extra components)
Function URL with AWS_IAM for third-party webhookWRONG (third-party cannot sign with AWS Sig V4)
Function URL with CodeSigningConfigArn conditionWRONG (code signing = deployment packages, not requests)

Real exam example: A third-party platform sends webhook requests signed with a secret key in headers. Need a public HTTPS endpoint processed by Lambda with least development effort:

  • Correct: Create Lambda Function URL with AuthType: NONE + resource-based policy allowing public invoke + custom signature validation inside the Lambda function
  • Wrong: API Gateway + Lambda Authorizer (works but MORE effort β€” two components instead of one)
  • Wrong: Function URL with AWS_IAM (third-party platform cannot create AWS Sig V4 signatures)
  • Wrong: CodeSigningConfigArn condition (that validates deployment packages, not incoming HTTP requests)

Key Distinctions to Memorize:

TermWhat It DoesExam Confusion
FunctionUrlAuthTypeControls who can call the Function URL (NONE or IAM)Auth for HTTP callers
CodeSigningConfigValidates deployment package integrity (code trust)Auth for code deployments
Lambda AuthorizerCustom auth logic as a separate Lambda functionAPI Gateway only
Cognito AuthorizerJWT validation from Cognito User PoolAPI Gateway only

Task 1.3: Use Data Stores in Application Development

1.3.1 Amazon DynamoDB

Core Concepts:

  • Partition Key (PK): Determines data distribution; must be high cardinality
  • Sort Key (SK): Optional; enables range queries within a partition
  • Item size: Max 400 KB

Capacity Modes:

ModeBillingBest For
On-DemandPay per requestUnpredictable traffic, new tables
ProvisionedSet RCU/WCU (auto-scaling OK)Predictable traffic, cost optimization

RCU / WCU Calculations:

  READ (RCU):
  1 RCU = 1 strongly consistent read/sec for item <= 4 KB
        = 2 eventually consistent reads/sec for item <= 4 KB

  RCU = (reads/sec x ceil(item_KB / 4)) / consistency_factor
    Strongly consistent:   factor = 1
    Eventually consistent: factor = 2  (HALF cost)
    Transactional:         factor = 0.5 (DOUBLE cost)

  WRITE (WCU):
  1 WCU = 1 write/sec for item <= 1 KB

  WCU = writes/sec x ceil(item_KB / 1)
  Transactional writes: multiply by 2

Example: 150 eventually consistent reads/sec, 3.5 KB items: RCU = 150 x ceil(3.5/4) / 2 = 150 x 1 / 2 = 75 RCU

Indexes:

FeatureLSI (Local Secondary)GSI (Global Secondary)
Partition keySame as base tableDifferent from base table
Sort keyDifferent from base tableDifferent from base table
Creation timeAt table creation ONLYAnytime
CapacityShares table RCU/WCUHas its OWN RCU/WCU
ConsistencyStrong or EventuallyEventually ONLY
Max per table520
Size limit10 GB per partition keyNo limit

ProvisionedThroughputExceededException on writes? Check if GSI WCU is less than base table WCU.

Query vs Scan:

OperationWhat It ReadsCostUse When
QueryItems matching PK (+ SK)EfficientYou know the partition key
ScanEntire tableExpensiveNeed all data (avoid if possible)
  • Scan applies FilterExpression AFTER reading (still consumes full RCU)
  • Optimize Scan: parallel scan with rate limiting; set Limit to control page size

DynamoDB Streams:

  • Captures item-level changes: INSERT, MODIFY, DELETE
  • StreamViewType: KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES
  • 24-hour retention (Lambda must run within 24h or data loss)
  • Lambda polls streams via Event Source Mapping (synchronous invocation)

Transactions:

APIBehaviorCostNotes
TransactWriteItemsAll-or-nothing (ACID)2x WCUUp to 100 items, 4 MB total
TransactGetItemsConsistent read of multiple items2x RCUUp to 100 items, 4 MB total
BatchWriteItemBest-effort (NOT atomic)1x WCUUp to 25 items, no UpdateItem
BatchGetItemBest-effort1x RCUUp to 100 items, 16 MB max

Batch Operations β€” Partial Results and UnprocessedKeys (exam favorite!):

BatchGetItem returns partial results (UnprocessedKeys) when:

  • Response size exceeds 16 MB limit
  • Table’s provisioned throughput is exceeded
  • More than 1 MB per partition is requested
  • Internal processing failure occurs

BatchWriteItem returns partial results (UnprocessedItems) when:

  • Table’s provisioned throughput is exceeded
  • Internal processing failure occurs

How to Handle UnprocessedKeys / UnprocessedItems:

ApproachReliable?Why
Exponential backoff with jitter (randomized delay)YESReduces request frequency, avoids thundering herd
Use AWS SDK (built-in retry + exponential backoff)YESSDK handles retry logic automatically
Immediately retry the batch requestNOStill throttled; high chance of failing again
Increase RCUs / enable Auto ScalingPartialHelps with throughput but partial results can still occur due to size limits
Create a GSINOGSI doesn’t change BatchGetItem behavior

Exam example: Python script uses BatchGetItem, frequently gets UnprocessedKeys. Most reliable handling?

  1. Exponential backoff with randomized delay between retries
  2. Use AWS SDK (has built-in automatic retry + exponential backoff)

Wrong: Immediate retry (still throttled), increase RCUs (doesn’t fix size-limit partials), GSI (irrelevant to batch ops)

Batch Limits Quick Reference:

APIMax ItemsMax SizePartial Result Key
BatchGetItem10016 MBUnprocessedKeys
BatchWriteItem2516 MBUnprocessedItems
TransactGetItems1004 MBAll-or-nothing (no partial)
TransactWriteItems1004 MBAll-or-nothing (no partial)

Optimistic Locking: Use version number attribute with ConditionExpression.

TTL: Auto-delete expired items (no WCU cost); eventually consistent (up to 48h delay).

DAX vs ElastiCache:

FeatureDAXElastiCache
PurposeDynamoDB-specific cacheGeneral-purpose cache
APISame as DynamoDB (drop-in)Custom cache logic in your app
ConsistencyEventually consistent onlyYou control
Data typesDynamoDB items/queriesAny (aggregated, computed, sessions)
Best forCaching DynamoDB readsComputed results, multi-source cache

1.3.2 Amazon S3

Server-Side Encryption:

TypeKey ManagementHeader
SSE-S3AWS managedx-amz-server-side-encryption: AES256
SSE-KMSKMS keyx-amz-server-side-encryption: aws:kms + optional key ID
SSE-CCustomer key3 headers: algorithm, key (base64), key MD5
  • SSE-KMS: Each operation calls KMS API and counts against KMS quota
  • Enforce encryption: Bucket policy deny s3:PutObject without encryption header

Storage Classes:

ClassAccess PatternRetrieval FeeMin Duration
S3 StandardFrequentNoneNone
S3 Intelligent-TieringUnknown / changingNoneNone
S3 Standard-IAInfrequent, rapid accessPer GB30 days
S3 One Zone-IAInfrequent, single AZ OKPer GB30 days
S3 Glacier InstantQuarterly, millisecond accessPer GB90 days
S3 Glacier Flexible1-2x/year, mins-hoursPer GB90 days
S3 Glacier Deep Archive1x/year, 12-48 hoursPer GB180 days

Key Features:

  • Presigned URLs: Temporary access to private objects (upload or download)
  • Event Notifications: Targets Lambda, SQS, SNS, EventBridge
  • Versioning: Protects against accidental deletion (delete markers)
  • MFA Delete: Requires MFA for permanent version deletion
  • Lifecycle Rules: Transition between storage classes or expire objects

CORS:

  • Configure on the target bucket (the one being accessed cross-origin)
  • Lambda Proxy integration: Return CORS headers from Lambda function
  • Non-proxy integration: Enable CORS in API Gateway console

1.3.3 Amazon ElastiCache

Redis vs Memcached:

FeatureRedisMemcached
ReplicationMulti-AZ with auto-failoverNo replication
PersistenceAOF / RDB snapshotsNo persistence
Data typesStrings, lists, sets, hashesSimple key-value only
Pub/SubYesNo
ThreadingSingle-threadedMulti-threaded
Use caseHA, persistence, complex dataSimple caching, max throughput

Caching Strategies:

StrategyHow It WorksProsCons
Lazy LoadingCache miss then fetch DB then cache itOnly caches needed dataStale data, cache-miss penalty
Write-ThroughWrite to cache AND DB simultaneouslyAlways freshWrite penalty, caches all data
Write-BehindWrite to cache then async write to DBFast writesData loss risk

Best practice: Write-Through + TTL = fresh data + automatic cleanup of unused entries.

1.3.4 Amazon OpenSearch

  • Full-text search, log analytics, real-time dashboards
  • Common pattern: DynamoDB Streams to Lambda to OpenSearch
  • Use when DynamoDB cannot meet search requirements (full-text, fuzzy matching)

DOMAIN 2 β€” Security (26%)


Task 2.1: Implement Authentication and Authorization

2.1.1 IAM Core Concepts

Policy Evaluation Logic:

  1. All requests DENIED by default
  2. Evaluate all applicable policies
  3. Explicit DENY always wins (overrides any Allow)
  4. Explicit ALLOW grants access (if no Deny)
  5. If no Allow found then implicit deny

Policy Types:

Policy TypeScopeNotes
Service Control PolicyOrganization / OU / AccountSets maximum permissions boundary
Permissions BoundaryIAM user / roleSets max permissions for entity
Identity-basedIAM user / role / groupInline or managed policies
Resource-basedS3, SQS, Lambda, KMS, etc.Cross-account without AssumeRole
Session policySTS sessionLimits assumed role permissions

Key Distinctions:

  • Users: Long-term credentials (access keys); for humans or CI/CD
  • Roles: Temporary credentials via STS; for services, cross-account, federation
  • Instance Profile: Wrapper around IAM role for EC2 instances
  • Always prefer roles over access keys

2.1.2 STS (Security Token Service)

APIUse Case
AssumeRoleCross-account access, role switching
AssumeRoleWithWebIdentityOIDC federation (Google, Facebook, Cognito)
AssumeRoleWithSAMLSAML 2.0 federation (Active Directory)
GetSessionTokenMFA-protected API calls (ONLY STS API with MFA!)
GetFederationTokenProxy apps issuing temp credentials
DecodeAuthorizationMessageDecode UnauthorizedOperation error details

Cross-Account Access Pattern:

  PRODUCTION ACCOUNT                     DEVELOPMENT ACCOUNT
  1. Create IAM Role with               3. Create IAM Policy allowing
     Trust Policy: Dev Account               sts:AssumeRole on Prod Role ARN
  2. Attach permissions to Role          4. Attach to Dev IAM users/roles

Role created in account WITH the resource. Trust policy specifies WHO can assume it.

2.1.3 Amazon Cognito

User Pools (Authentication β€” β€œWho are you?”):

  • User directory: sign-up, sign-in, password policies
  • Social login: Google, Facebook, Apple, SAML, OIDC
  • MFA, adaptive authentication, account recovery
  • Returns JWTs: ID Token (user identity claims), Access Token (API access scopes), Refresh Token
  • Hosted UI with customizable branding
  • Directly integrates with API Gateway as a native Cognito Authorizer
  • Cannot grant AWS service credentials directly
  • Token stored client-side (e.g., browser local storage) and sent in Authorization header

Identity Pools / Federated Identities (Authorization β€” β€œWhat can you access?”):

  • Exchanges tokens (from User Pool, Google, Facebook, SAML) for temporary AWS credentials (via STS)
  • Maps authenticated and unauthenticated users to IAM roles
  • Supports guest / unauthenticated access
  • Returns Cognito ID (CognitoIdentityId) β€” a unique identifier for the user
  • The Cognito ID is then used to obtain temporary, limited-privilege AWS credentials
  • Does NOT directly integrate with API Gateway as an authorizer
  • Use when your app needs to call AWS services directly (S3, DynamoDB) from client-side

Identity Pool with External IdP β€” Full Flow:

  FLOW 3: External IdP + Identity Pool (mobile apps, federated access)

  β”Œβ”€β”€β”€β”€β”€β”€β”  SDK    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” OAuth/OIDC  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  returns  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚Mobile│──────>  β”‚ Identity  β”‚   token     β”‚   Amazon      β”‚ Cognito   β”‚ Cognito  β”‚
  β”‚ App  β”‚  login  β”‚ Provider  │────────────>β”‚   Cognito     │───ID────> β”‚ ID       β”‚
  β””β”€β”€β”€β”€β”€β”€β”˜         β”‚(Google,   β”‚             β”‚  (Identity    β”‚           β”‚(unique   β”‚
                   β”‚ Facebook, β”‚             β”‚   Pool)       β”‚           β”‚ user ID) β”‚
                   β”‚ SAML...)  β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                              β”‚
                                                                    GetCredentialsForIdentity
                                                                              β”‚
                                                                              v
                                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                                    β”‚ Temp AWS Creds    β”‚
                                                                    β”‚ (AccessKeyId,     β”‚
                                                                    β”‚  SecretAccessKey, β”‚
                                                                    β”‚  SessionToken)    β”‚
                                                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                              β”‚
                                                                    S3, DynamoDB, SNS...

What Each β€œCognito ___” Term Means (exam loves these distractors):

TermWhat It IsReal?
Cognito IDUnique user identifier returned by Identity PoolYES β€” correct answer
Cognito Key PairNot a real Cognito conceptNO β€” distractor
Cognito SDKDevelopment toolkit to interact with CognitoExists but not a return value
Cognito APIAPI interface for Cognito serviceExists but not a return value

Exam example: Mobile app authenticates with IdP using provider’s SDK, passes OAuth/OIDC token to Cognito. What is returned to provide temporary AWS credentials?

  • Answer: Cognito ID β€” Identity Pool returns a Cognito ID, which is then used to get temporary, limited-privilege AWS credentials
  • The Cognito ID uniquely identifies the user across all federated identity providers

The Two Flows β€” Critical to Understand:

  FLOW 1: User Pool + API Gateway (most common exam scenario)
  β”Œβ”€β”€β”€β”€β”€β”€β” sign-in  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  JWT    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” Cognito   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ User │─────────>β”‚ User Pool │──token──>β”‚ Browser / β”‚ Authorizerβ”‚ API GW   β”‚
  β”‚      β”‚          β”‚           β”‚         β”‚ App       │──────────>β”‚ (validatesβ”‚
  β””β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  header:  β”‚  JWT)     β”‚
                                                        Authorization β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  - API Gateway validates JWT natively (no Lambda needed)
  - Set token source = name of header (usually "Authorization")
  - Create authorizer in API GW console using User Pool ID

  FLOW 2: User Pool + Identity Pool + AWS Services
  β”Œβ”€β”€β”€β”€β”€β”€β” sign-in  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  JWT   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  STS   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ User │─────────>β”‚ User Pool │──token─>β”‚ Identity Pool │──────>β”‚ Temp AWS β”‚
  β”‚      β”‚          β”‚           β”‚        β”‚               β”‚       β”‚ Creds    β”‚
  β””β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                       β”‚
                                                              S3, DynamoDB, etc.
  - Identity Pool exchanges JWT for IAM credentials
  - App calls AWS services DIRECTLY (not through API Gateway)
  - Use when client needs S3.putObject, DynamoDB.getItem, etc.

Exam Trap β€” User Pool vs Identity Pool for API Gateway:

Question PatternAnswer
”JWT authorizer for API Gateway”User Pool (NOT Identity Pool)
β€œReactJS app + Cognito + JWT in local storage + API Gateway”User Pool + Cognito Authorizer
”Token source header for API Gateway authorizer”Set header on User Pool authorizer
”App needs to call S3/DynamoDB directly from browser”Identity Pool (for AWS creds)
β€œGuest access to AWS resources”Identity Pool
”User Pool or Identity Pool for API Gateway?”Always User Pool

Real exam example: A ReactJS app on S3 uses Cognito SDK for sign-up/sign-in, stores JWT in local storage, and uses JWT to authorize API Gateway calls. The correct steps are:

  1. Create a Cognito User Pool (for sign-up/sign-in and JWT issuance)
  2. On API Gateway console, create an authorizer using the Cognito User Pool ID
  3. Set the header name (e.g., Authorization) as the token source pointing to the User Pool authorizer

Identity Pool is NOT needed here because the app only calls API Gateway (not AWS services directly).

Complete Decision Guide:

ScenarioService
User sign-up / sign-in / user directoryUser Pool
JWT tokens for API Gateway authorizationUser Pool (Cognito Authorizer)
Token source header for API GatewayUser Pool authorizer config
Temporary AWS credentials (S3, DynamoDB from client)Identity Pool
Guest / unauthenticated access to AWS resourcesIdentity Pool
Social login + access S3 directly from appUser Pool + Identity Pool
Social login + access API GatewayUser Pool (Cognito Authorizer)
Cross-device sync (single user key-value)Cognito Sync
Multi-user real-time shared dataAppSync (NOT Cognito Sync)

2.1.4 API Gateway Authentication

MethodHow It WorksUse When
IAM (AWS_IAM)Sig V4 signed requestsAWS users/roles, cross-account
Cognito User Pool AuthorizerValidates JWT from User Pool nativelyUser pool-authenticated clients
Lambda Authorizer (TOKEN)Custom auth logic on bearer tokenCustom/3rd-party auth, Identity Pool tokens
Lambda Authorizer (REQUEST)Custom auth on headers, query paramsMultiple identity sources
API KeysIdentification only (NOT authentication!)Usage tracking, throttling, quotas

Identity Pool + API Gateway (when needed):

  • Identity Pool does NOT have a native API Gateway authorizer
  • If you must use Identity Pool tokens with API Gateway, use a Lambda Authorizer to validate
  • But the standard pattern is: User Pool JWT + Cognito Authorizer (simpler, no Lambda needed)

Resource Policies: JSON policies on the API itself for cross-account access or IP restrictions.


Task 2.2: Implement Encryption Using AWS Services

2.2.1 AWS KMS (Key Management Service)

Key Types:

TypeManagementRotationUse Case
AWS managed key (aws/s3)AWSAuto every yearDefault for AWS services
Customer managed key (CMK)YouOptional (enable auto-rotate)Custom control, policies
AWS owned keyAWSVariesInternal AWS use

Envelope Encryption (for data larger than 4 KB):

  ENCRYPT:
  1. Call GenerateDataKey -> returns plaintext key + encrypted key
  2. Encrypt data with the plaintext key (client-side)
  3. DELETE plaintext key from memory
  4. Store encrypted data + encrypted key together

  DECRYPT:
  1. Send encrypted key to KMS (Decrypt API) -> returns plaintext key
  2. Decrypt data with the plaintext key
  3. DELETE plaintext key from memory
  • KMS can only directly encrypt/decrypt up to 4 KB
  • For larger data you MUST use envelope encryption
  • GenerateDataKey vs GenerateDataKeyWithoutPlaintext (encrypted key only, for later use)

KMS Key Policies:

  • Every KMS key must have a key policy (resource-based)
  • Default: Gives the account root user full access
  • Cross-account: Key policy must allow external account AND external account needs IAM permissions

KMS API Quota:

  • 5,500 - 30,000 requests/sec per region
  • SSE-KMS on S3: each upload/download calls KMS and can hit quota
  • Fix: request quota increase, use S3 Bucket Keys, or switch to SSE-S3

2.2.2 KMS vs CloudHSM

FeatureKMSCloudHSM
HSM tenancyMulti-tenantSingle-tenant (dedicated)
Key managementAWS manages HSMsYou manage keys and HSMs
FIPS complianceLevel 2Level 3
Integration100+ AWS servicesCustom key store for KMS
Use caseMost encryption needsRegulatory compliance, full control

2.2.3 Encryption at Rest and in Transit

ServiceAt RestIn Transit
S3SSE-S3, SSE-KMS, SSE-CHTTPS (enforce via bucket policy)
DynamoDBAWS owned key (default) or KMS CMKTLS (automatic)
EBSKMS-encrypted volumesEncrypted between EC2 and EBS
RDSKMS encryption at creationSSL/TLS certificates
SQSSSE-SQS or SSE-KMSHTTPS
KinesisKMS server-side encryptionTLS

2.2.4 ACM (AWS Certificate Manager)

  • Free public SSL/TLS certificates for AWS services
  • Auto-renewal for ACM-issued certificates
  • Integrates with: ALB, CloudFront, API Gateway
  • Cannot use ACM certificates directly on EC2

Task 2.3: Manage Sensitive Data in Application Code

2.3.1 Parameter Store vs Secrets Manager

FeatureParameter StoreSecrets Manager
RotationManual (custom Lambda)Built-in auto-rotation
CostFree (standard tier)$0.40/secret/month
Max size4 KB (std), 8 KB (adv)64 KB
RDS integrationNo native rotationNative rotation for RDS
Cross-regionNoYes (replica secrets)
EncryptionSecureString with KMSAlways encrypted with KMS
Best forConfig values, feature flagsCredentials needing rotation

Parameter Store Tiers:

TierMax SizeCostFeatures
Standard4 KBFreeNo policies
Advanced8 KBPaidExpiration, NoChangeNotification

CloudFormation Dynamic References:

  • {{resolve:ssm:paramName:version}} for plaintext parameters
  • {{resolve:ssm-secure:paramName:version}} for SecureString parameters
  • {{resolve:secretsmanager:secretId:key}} for Secrets Manager

2.3.2 Best Practices for Sensitive Data

  • Never store credentials in code, Git, or CloudFormation parameters in plaintext
  • Lambda: Use environment variables encrypted with KMS for sensitive values
  • ECS: Reference Secrets Manager or Parameter Store in task definitions
  • Use IAM roles instead of access keys whenever possible

DOMAIN 3 β€” Deployment (24%)


Task 3.1: Prepare Application Artifacts for Deployment

3.1.1 Lambda Packaging

MethodDetails
Zip deployment50 MB compressed, 250 MB unzipped (incl. layers)
Container imageUp to 10 GB; must implement Lambda Runtime API
Inline (ZipFile)CloudFormation only; Node.js and Python; source code only
LayersShared libraries; max 5 per function; extract to /opt/

3.1.2 Container Images (ECS/EKS)

  • Dockerfile to docker build to push to Amazon ECR
  • ECR: Managed container registry with image scanning
  • ECS Task Definition references ECR image URI
  • Multi-stage builds reduce image size (build + runtime stages)

3.1.3 Elastic Beanstalk Source Bundle

  • ZIP or WAR containing application code
  • .ebextensions/*.config for custom resources and settings (YAML)
  • env.yaml for environment manifest
  • Dockerrun.aws.json for multi-container Docker
  • cron.yaml for periodic worker tasks
  • Procfile to define processes

Task 3.2: Test Applications in Development Environments

3.2.1 SAM Local Testing

  sam local invoke            Invoke Lambda locally with event payload
  sam local start-api         Start local API Gateway + Lambda
  sam local start-lambda      Start Lambda endpoint for SDK testing
  sam local generate-event    Generate sample event payloads
  • Requires Docker for local Lambda simulation

3.2.2 CDK + SAM Local Testing (Exam Favorite!)

The exact two-step flow:

  Step 1: cdk synth --stack StackName
          |
          v
  Generates CloudFormation template in cdk.out/
  (e.g., cdk.out/MyStack.template.json)

  Step 2: sam local invoke -t cdk.out/MyStack.template.json MyFunctionLogicalId
          |
          v
  SAM reads the synthesized template, finds the Lambda,
  spins up Docker container, invokes locally

Full command reference for CDK + SAM local testing:

StepCommandPurpose
1cdk synth (with optional --stack StackName)Generate CloudFormation template to cdk.out/
2asam local invoke -t cdk.out/template.json FunctionIdInvoke a specific Lambda locally
2bsam local start-api -t cdk.out/template.jsonStart local API Gateway + Lambda
2csam local start-lambda -t cdk.out/template.jsonStart local Lambda endpoint for SDK testing

Exam Trap β€” What is NOT needed for local testing:

Command / ActionNeeded for Local Testing?Why
cdk synthYESGenerates the template SAM needs
sam local invoke -t ...YESInvokes the function locally using template
cdk bootstrapNOSets up deployment infra (S3 bucket), not local
sam packageNOUploads code to S3 for deployment, not local
sam deployNODeploys to AWS, not local
cdk deployNODeploys to AWS, not local

Exam example: CDK app with L2 constructs, SAM and CDK configured locally. What TWO steps to test Lambda locally?

  1. Run cdk synth to generate CloudFormation template (specify stack name)
  2. Run sam local invoke with -t pointing to the synthesized template and the function logical ID

Wrong: sam package (that’s for S3 upload/deployment), cdk bootstrap (that’s for deployment prep)


Task 3.3: Automate Deployment Testing

3.3.1 CodeBuild

buildspec.yml structure:

version: 0.2
env:
  variables:
    KEY: "value"
  parameter-store:
    DB_PASS: /app/db-password
  secrets-manager:
    SECRET: my-secret:key
phases:
  install:
    runtime-versions:
      nodejs: 18
    commands:
      - npm install
  pre_build:
    commands:
      - npm test
  build:
    commands:
      - npm run build
  post_build:
    commands:
      - echo "Build complete"
artifacts:
  files:
    - '**/*'
  base-directory: dist
cache:
  paths:
    - node_modules/**/*
  • Build projects defined in buildspec.yml (NOT appspec.yml)
  • Artifacts stored in S3
  • Environment variables from Parameter Store and Secrets Manager
  • VPC support for accessing private resources during build

Task 3.4: Deploy Code Using AWS CI/CD Services

3.4.1 CodePipeline

  Source --> Build --> [Test] --> [Manual Approval] --> Deploy
  • Source: CodeCommit, GitHub, S3, ECR
  • Build: CodeBuild
  • Deploy: CodeDeploy, CloudFormation, ECS, Elastic Beanstalk, S3

Manual Approval:

  • Pipeline pauses until approved, rejected, or times out
  • Default timeout: 7 days
  • SNS notification to approvers
  • IAM permission: codepipeline:PutApprovalResult
  • Use cases: production gate, compliance sign-off, change management

3.4.2 AWS CodeDeploy

Deployment Matrix:

PlatformIn-PlaceBlue/GreenAgent Required?
EC2YesYesYES (must be installed and running)
On-PremisesYesNoYES (must be installed and running)
LambdaNoYes (always)NO (managed by AWS)
ECSNoYes (always)NO (managed by AWS)

CodeDeploy Agent Details:

  • Must be installed and running on EC2 and On-Premises instances only
  • Agent polls CodeDeploy for deployment instructions
  • Install at scale via SSM Run Command
  • NOT required for Lambda or ECS (AWS manages natively)
  • DownloadBundle error: Check agent is running AND instance IAM role has S3 permissions

Traffic Shifting Strategies (Lambda / ECS):

StrategyBehavior
CanaryX% to new then wait then remaining (e.g., Canary10Percent5Minutes)
LinearEqual increments over time (e.g., Linear10PercentEvery1Minute)
AllAtOnce100% immediately

AppSpec File:

PlatformFormatKey Sections
EC2YAMLfiles (source to dest), hooks (lifecycle events)
LambdaYAML/JSONversion, resources (function, alias, versions)
ECSYAML/JSONversion, resources (task def, container, port)

EC2/On-Prem Lifecycle Hooks (in order):

#HookManaged ByCan You Script It?
1ApplicationStopUser (AppSpec)Yes β€” run scripts to stop current app
2DownloadBundleAgent onlyNO β€” cannot configure in AppSpec
3BeforeInstallUser (AppSpec)Yes β€” pre-install tasks (backup, decrypt)
4InstallAgent onlyNO β€” agent copies files per AppSpec
5AfterInstallUser (AppSpec)Yes β€” post-install (chmod, config)
6ApplicationStartUser (AppSpec)Yes β€” start/restart your application
7ValidateServiceUser (AppSpec)Yes β€” health checks, smoke tests

Exam key: DownloadBundle and Install are agent-managed only. You cannot write scripts for them in AppSpec. Any answer saying β€œconfigure DownloadBundle in AppSpec” is wrong.

DownloadBundle Failures β€” Deep Dive:

Error MessageRoot CauseFix
UnknownError: not opened for readingEC2 instance IAM profile lacks S3 read permissionsAdd s3:Get*, s3:List* to instance profile
DownloadBundle timeoutAgent cannot reach S3 (network/VPC issue)Check security groups, NACLs, VPC endpoints
DownloadBundle with access deniedS3 bucket policy denies the instance roleUpdate bucket policy OR instance profile
Agent not found / deployment stuckCodeDeploy agent not installed or not runningInstall agent via SSM Run Command; start service

Exam traps around DownloadBundle:

  • S3 versioning is NOT required for CodeDeploy to download bundles
  • DownloadBundle works in all regions (not region-restricted)
  • You cannot configure DownloadBundle in the AppSpec file (it’s agent-managed)
  • The most common cause is missing IAM permissions on the EC2 instance profile

Rollback:

  • Automatic rollback deploys last known good revision as a new deployment (new ID)
  • Does NOT restore previous deployment; creates a new one
  • Triggers: deployment failure or CloudWatch alarm breach

3.4.3 CloudFormation

Template Sections:

SectionRequired?Purpose
AWSTemplateFormatVersionNoTemplate version (2010-09-09)
DescriptionNoTemplate description
ParametersNoInput values at deploy time
MappingsNoStatic key-value lookup tables
ConditionsNoConditional resource creation
TransformNoMacros (SAM: AWS::Serverless-2016-10-31)
ResourcesYESAWS resources (ONLY required section)
OutputsNoExport values for cross-stack references

Key Intrinsic Functions:

FunctionPurpose
RefReference parameter or resource logical ID
Fn::GetAttGet attribute of a resource
Fn::JoinConcatenate strings with delimiter
Fn::SubString substitution with variables
Fn::SelectSelect item from list by index
Fn::ImportValueImport exported output from another stack
Fn::FindInMapLookup value in Mappings section

Cross-Stack References:

  • Stack A: Outputs with Export: Name: "VPC-ID"
  • Stack B: Fn::ImportValue: "VPC-ID"

Change Sets: Preview changes before executing. Shows adds, modifies, replaces.

Drift Detection: Identifies resources changed outside CloudFormation.

Helper Scripts (EC2):

ScriptPurpose
cfn-initInstall packages, create files, start services
cfn-signalSignal CloudFormation that instance is ready
cfn-hupDaemon detecting metadata changes, re-runs cfn-init
cfn-get-metadataRetrieve metadata from template

3.4.4 AWS SAM

  • CloudFormation extension for serverless; requires Transform: AWS::Serverless-2016-10-31

SAM Resource Types:

SAM ResourceEquivalent
AWS::Serverless::FunctionLambda + IAM Role + API GW + Events
AWS::Serverless::ApiAPI Gateway RestApi
AWS::Serverless::HttpApiAPI Gateway HttpApi (v2)
AWS::Serverless::SimpleTableDynamoDB Table
AWS::Serverless::LayerVersionLambda Layer

SAM CLI Commands:

CommandPurpose
sam initScaffold project (not needed if project exists)
sam buildInstall dependencies, prepare artifacts
sam deployPackage (zip + S3) + Deploy via CloudFormation (combined!)
sam local invokeLocal Lambda testing
sam local start-apiLocal API Gateway

sam deploy = sam package + deploy combined CloudFormation CLI requires TWO commands: aws cloudformation package then deploy

SAM Policy Templates: Predefined IAM policies like DynamoDBCrudPolicy, S3ReadPolicy, SQSPollerPolicy.

3.4.5 AWS CDK

  • Infrastructure as code (Python, TypeScript, Java, C#, Go)
  • Compiles to CloudFormation via cdk synth
CommandPurpose
cdk bootstrapFIRST command in new account/region (creates S3 for assets)
cdk synthGenerate CloudFormation template
cdk deployDeploy stack
cdk diffPreview changes
cdk destroyDelete stack
  • NoSuchBucket error means run cdk bootstrap
  • Constructs: L1 (raw CFN), L2 (opinionated defaults), L3 (patterns)

3.4.6 Elastic Beanstalk Deployments

StrategyDowntimeCapacityRollbackCost
All-at-onceYESReducedManual redeployLowest
RollingNoReducedManual redeployLow
Rolling + BatchNoFullManual redeployMedium
ImmutableNoFullTerminate new ASGHigher
Traffic SplittingNoFullReroute trafficHigher
Blue/GreenNoFullCNAME swapHighest
  • Blue/Green: Best for major platform changes
  • Immutable: Best for quick rollback without DNS complexity

3.4.7 CodeArtifact

  • Managed artifact repository for Maven, npm, pip, NuGet
  • Upstream repos: npmjs.com, Maven Central, PyPI
  • Cross-account sharing via resource policies

DOMAIN 4 β€” Troubleshooting and Optimization (18%)


Task 4.1: Assist in Root Cause Analysis

4.1.1 CloudWatch Logs

  • Log Groups: Container for log streams (one per application/service)
  • Log Streams: Sequence of events from a single source
  • Metric Filters: Extract metrics from log data (count ERROR occurrences)
  • Insights: Query and analyze log data with purpose-built query language
  • Subscription Filters: Real-time processing to Lambda, Kinesis, Firehose
  • Retention: Configure per log group (1 day to 10 years; default forever)

Lambda Logging:

  • Execution role needs: logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEvents
  • Managed policy: AWSLambdaBasicExecutionRole

4.1.2 CloudWatch Metrics and Alarms

Custom Metrics:

  • PutMetricData API to publish custom metrics
  • High-resolution: 1-second granularity (standard is 60 seconds)
  • Embedded Metric Format (EMF): Structured log auto-extracted as metric

Alarms:

StateMeaning
OKMetric within threshold
ALARMMetric breached threshold
INSUFFICIENT_DATANot enough data to evaluate
  • Actions: SNS, Auto Scaling, EC2, Lambda
  • Composite alarms: AND/OR logic across multiple alarms

4.1.3 CloudTrail

  • Records API calls (management events by default)
  • Data events (S3, Lambda) are opt-in with additional cost
  • Use for: auditing, compliance (β€œwho did what when”)
  • NOT for distributed tracing (use X-Ray)

4.1.4 Common Error Reference

ErrorRoot CauseFix
API Gateway 502Lambda wrong response formatReturn {statusCode, headers, body}
API Gateway 504Backend exceeded 29s timeoutOptimize Lambda or use async
Lambda 429Concurrency limit reachedReserved concurrency + backoff
DynamoDB ProvisionedThroughputExceededExceptionHot partition or low capacityBetter PK + exponential backoff
Lambda AccessDeniedExceptionExecution role missing permissionsUpdate execution role IAM policy
EC2 UnauthorizedOperationIAM policy missingsts:DecodeAuthorizationMessage
CDK NoSuchBucketCDK not bootstrappedRun cdk bootstrap
Lambda Unable to import moduleMissing deps in packageInstall locally + zip + upload
CodeBuild RequestError timeoutMissing proxy configAdd proxy to buildspec.yml
CodeDeploy DownloadBundle / not opened for readingEC2 IAM profile missing S3 permissionsAdd S3 read perms to instance profile
CodeDeploy DownloadBundle stuckAgent not running or network blockedCheck agent + SG + NACLs + VPC endpoints

Task 4.2: Instrument Code for Observability

4.2.1 AWS X-Ray

Core Concepts:

ConceptDescription
TraceEnd-to-end journey of a single request
SegmentWork done by a single service (auto-generated)
SubsegmentGranular downstream calls within a segment
AnnotationKey-value pair, indexed for search/filter
MetadataKey-value pair, NOT indexed for debug data
Service MapVisual graph of distributed application
SamplingRules controlling how many traces are recorded

Annotations vs Metadata:

FeatureAnnotationsMetadata
IndexedYES (searchable)NO
Value typesStrings, numbers, booleansAny type (objects, arrays)
Use forFiltering by user_id, envDebug data you do not search
APIputAnnotation(key, value)putMetadata(key, value)

Subsegment Namespaces:

NamespaceType of Call
awsAWS SDK call (DynamoDB, S3, SQS)
remoteExternal HTTP API call
(none)Custom subsegment (your own code logic)

Trace Analysis APIs:

  1. GetTraceSummaries to filter traces by annotations and get trace IDs
  2. BatchGetTraces to get full traces by ID (no filtering)

Integration by Service:

ServiceHow to Enable
LambdaEnable checkbox (TracingConfig: Active); automatic
ECS / FargateX-Ray daemon as sidecar container (UDP port 2000!)
Elastic Beanstalk.ebextensions/xray.config
EC2Install X-Ray daemon + AWSXRayDaemonWriteAccess role
API GatewayEnable tracing in stage settings

β€œInstall X-Ray daemon on Lambda” is WRONG. Just enable the checkbox. X-Ray daemon on ECS uses UDP port 2000 (not TCP).

Sampling Rules:

  • Reservoir: Fixed traces per second (guaranteed)
  • Rate: Percentage of additional traces beyond reservoir
  • Default: 1 request/sec + 5% of additional requests

X-Ray IAM Policies:

RolePolicy Needed
X-Ray daemon (EC2/ECS)AWSXRayDaemonWriteAccess
Lambda with X-RayAutomatic (just enable)
View traces in consoleAWSXrayReadOnlyAccess
Full accessAWSXrayFullAccess

4.2.2 CloudWatch Contributor Insights

  • Identify top contributors (e.g., top IPs causing errors)
  • DynamoDB: Identify most accessed items (hot keys)

Task 4.3: Optimize Applications Using AWS Services

4.3.1 Lambda Optimization

OptimizationApproach
Reduce cold startsProvisioned concurrency; keep functions warm
Faster executionIncrease memory (= more CPU); optimize code
Reduce package sizeUse layers; remove unused deps; container images
Reuse connectionsInitialize SDK clients OUTSIDE the handler
CachingStore data in /tmp; use global variables
Async processingDecouple with SQS/SNS; return early

4.3.2 DynamoDB Optimization

GoalApproach
Fix hot partitionsHigh-cardinality PK; add random suffix if needed
Read optimizationDAX for microsecond reads; ElastiCache for computed
Write optimizationBatch writes; on-demand for spiky traffic
Cost optimizationEventually consistent reads (half cost); TTL for cleanup
Query optimizationUse Query not Scan; project only needed attributes
GSI throttle preventionEnsure GSI WCU >= base table WCU

4.3.3 S3 Performance

OptimizationDetail
Upload speedMultipart upload (recommended for files larger than 100 MB)
Download speedS3 Transfer Acceleration (uses CloudFront edge)
Byte-range fetchesDownload only portions of an object
S3 SelectQuery data in place using SQL (filter before download)
Request rate3,500 PUT + 5,500 GET per prefix per second

4.3.4 Caching Decision Tree

  DynamoDB reads with known keys?
    YES --> DAX

  Computed/aggregated data or multi-source?
    YES --> ElastiCache (Redis/Memcached)

  API responses?
    YES --> API Gateway caching

  Static content?
    YES --> CloudFront

4.3.5 CloudFront

Cache Update Strategies (exam favorite!):

StrategyImmediate?CostHow It Works
Versioned file namesYESFREEChange URL (e.g., img_v2.jpg); new URL = cache miss = fresh content
InvalidationYESCosts $$Removes objects from edge caches; first 1,000 paths free/month, then $0.005/path
Wait for TTL expirationNOFreeObjects served stale until TTL expires
Disable/re-enable distributionNOFreeDoes NOT clear cache; causes downtime

Exam trap: β€œFast AND cost-efficient” = versioned file names (not invalidation!)

  • Invalidation is fast but NOT cost-efficient for thousands of objects
  • Versioned file names are both fast AND free
  • Waiting for expiration is free but NOT fast
  • Disabling distribution doesn’t clear cache and causes downtime

Other CloudFront Features:

  • CloudFront Functions: Lightweight edge logic (viewer request/response), JavaScript only, < 1ms
  • Lambda@Edge: Heavier processing (origin request/response), Node.js/Python, up to 30s
  • CloudFront-Viewer-Country header for geo-routing
  • Origin Access Control (OAC): Restrict S3 access to CloudFront only (replaces OAI)
  • S3 Transfer Acceleration: Uses CloudFront edge for faster S3 uploads (different from CloudFront distribution)

APPENDIX A β€” Service Limits Quick Reference

ServiceKey Limits
Lambda timeout15 minutes (900 seconds)
Lambda memory128 MB - 10,240 MB
Lambda concurrent1,000 (soft limit, per account per region)
Lambda package50 MB zip, 250 MB unzipped, 5 layers, 10 GB container
Lambda /tmp512 MB free, up to 10 GB
API Gateway timeout29 seconds integration timeout
API Gateway TPS10,000 requests/second (account level)
API Gateway cache TTL0 - 3600 seconds (default 300)
DynamoDB item size400 KB max
DynamoDB RCU1 RCU = 4 KB (strong), 8 KB (eventual)
DynamoDB WCU1 WCU = 1 KB/sec
DynamoDB LSI5 per table (creation only)
DynamoDB GSI20 per table (anytime)
DynamoDB Streams24-hour retention
SQS Standard TPSUnlimited
SQS FIFO TPS300 (3,000 with batching)
SQS message size256 KB (up to 2 GB with Extended Client)
SQS retention1 min - 14 days (default 4 days)
SQS visibility0 - 12 hours (default 30 seconds)
Kinesis retention24 hours - 365 days
KMS direct encrypt4 KB max
KMS API quota5,500 - 30,000 req/sec per region
Cognito Sync1 MB per dataset, 20 datasets per identity
Step Functions events25,000 execution history events (standard)
CloudFormation500 resources per stack

APPENDIX B β€” Exam Strategy

Key Phrases and Their Answers:

Phrase in QuestionLikely Answer Direction
”Least operational effort”Managed service, built-in feature
”Most secure”IAM roles, least privilege, encryption
”Cost-effective”Query over Scan, binpack, on-demand, reserved
”Without code changes”ALB OIDC, CloudFront, API caching
”Near real-time”DynamoDB Streams, Kinesis, EventBridge
”Exactly-once”SQS FIFO (NOT Standard)
β€œCross-account”AssumeRole + trust policy
”MFA protected”GetSessionToken
”Ordering guaranteed”SQS FIFO, Kinesis (per shard)
β€œDecouple”SQS (NOT Kinesis unless streaming needed)

Service Confusion Matrix:

ScenarioDO NOT PickDO Pick
Simple decouplingKinesisSQS
Serverless deployRaw CloudFormationSAM
Coordinate LambdasDirect invokeStep Functions
Feature flagsLambda + SSMAppConfig
Distributed tracingCloudWatch LogsX-Ray
API call auditingX-RayCloudTrail
npm / Maven repositoryECRCodeArtifact
Cross-device sync (1 user)AppSyncCognito Sync
Multi-user real-timeCognito SyncAppSync
Infra as code in PythonCloudFormation YAMLCDK
DB credential rotationParameter StoreSecrets Manager
Container image registryS3ECR
Third-party webhook (least effort)API GW + Lambda AuthLambda Function URL (NONE)
JWT auth for API GatewayIdentity PoolUser Pool (Cognito Authorizer)
Public HTTPS for LambdaAPI Gateway (overkill)Lambda Function URL

When Stuck Between Two Answers:

  1. Does it follow least privilege?
  2. Does it use a managed/native service?
  3. Does it address the root cause (not symptoms)?
  4. Is it the simplest path meeting ALL requirements?

APPENDIX C β€” Additional Service Cards

AWS AppSync: Managed GraphQL; real-time subscriptions via WebSocket; offline support with conflict resolution.

AWS AppConfig: Feature flags and dynamic configuration; gradual rollout without deployment; preferred over Lambda + Parameter Store.

Amazon ECS Task Placement:

StrategyBehaviorUse Case
binpackPack tightly (fewest instances)Cost optimization
spreadDistribute across AZs or instancesHigh availability
randomRandom placementTesting

ECS Roles:

RoleWho Uses ItFor What
Execution RoleECS AgentPull ECR images, push CloudWatch logs
Task RoleYour containerCall AWS APIs (S3, DynamoDB, SNS, etc.)

EC2 Instance Metadata:

  • http://169.254.169.254/latest/meta-data/ for instance details
  • http://169.254.169.254/latest/user-data/ for launch scripts
  • IMDSv2 (recommended): Requires session token

ALB: Layer 7; OIDC auth on HTTPS:443 (no code changes); X-Forwarded-For for client IP; Lambda targets supported. NLB is Layer 4 with no OIDC and no Lambda targets.

SQS Extended Client Library: Java SDK only. Messages up to 2 GB via S3 storage. Not available via CLI, console, or other SDKs.


AWS DVA-C02 Exam-Aligned Study Guide | March 2026