Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

CloudFront, IAM, Lambda and DynamoDB Interview Questions (Deep Dive): 90 Advanced Questions with CLI Examples

This page has 90 deep-dive interview questions on four services that come up in almost every AWS interview: CloudFront (30), IAM (20), Lambda (20) and DynamoDB (20). The basics of each are in Sets 1 and 2 and in the hands-on pages of Set 3. Here we go into the details that separate someone who has read about a service from someone who has run it in production.

1. An everyday example: a city's delivery network

Why these four services together?

A typical modern AWS application uses all four: CloudFront delivers the website and API, IAM decides who can do what, Lambda runs the code, and DynamoDB stores the data. Interviewers often follow one request through all of them.

Think of a city's delivery network. CloudFront is the chain of local shops that keep popular items close to customers. IAM is the security desk that checks every badge. Lambda is the team of on-call workers who appear only when there is a job. DynamoDB is the huge, well-labelled warehouse where every item has an exact shelf address.

How to use this page

  • Practise with a small CloudFront distribution in front of an S3 bucket, a Lambda function and a DynamoDB table in a test account.
  • Run read-only commands first; invalidations, provisioned concurrency and global tables have costs.
  • All IDs are examples, such as account 111122223333 and distribution E1ABCDEXAMPLE.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. How do you create a CloudFront invalidation from the CLI and check that it finished? Fresher
aws cloudfront create-invalidation --distribution-id E1ABCDEXAMPLE --paths "/index.html" "/css/*"

Output:

{"Invalidation": {"Id": "I2J3K4L5EXAMPLE", "Status": "InProgress"}}
aws cloudfront get-invalidation --distribution-id E1ABCDEXAMPLE --id I2J3K4L5EXAMPLE --query Invalidation.Status

Output:

"Completed"

edge caches will fetch fresh copies of those paths on the next request. A wildcard path counts as one path for billing purposes. Invalidations do not clear users' browser caches.

Q2. What are CloudFront managed cache policies such as CachingOptimized and CachingDisabled? Fresher

Managed cache policies are ready-made policies from AWS:

  • CachingOptimized: long default TTLs, cache key without query strings, headers or cookies, and compression enabled. Good for static files.
  • CachingDisabled: TTL of 0, so every request goes to the origin. Good for dynamic APIs that must not be cached.
  • Others exist, for example policies that include query strings for media or Elemental services.

Use managed policies where they fit; create a custom policy only when you need specific headers, cookies or query strings in the cache key.

Q3. What is a CloudFront trusted key group? Fresher

A key group is a set of public keys that CloudFront trusts for verifying signed URLs and signed cookies.

  • You upload a public key to CloudFront and add it to a key group.
  • You attach the key group to the cache behaviour that serves private content.
  • Your application signs URLs or cookies with the matching private key (kept in Secrets Manager, never in code).

Key groups replaced the old method of using root-account CloudFront key pairs, and they allow rotation by adding a new key before removing the old one.

Q4. You added www.shop.example.com to a distribution. What else must be in place for HTTPS to work? Fresher
  • The domain must be listed as an alternate domain name (CNAME) on the distribution.
  • An ACM certificate in us-east-1 (or an imported certificate) must cover that name, either exactly or with a wildcard, and be attached to the distribution.
  • DNS must point the name to the distribution (a Route 53 alias record or a CNAME to the dxxxx.cloudfront.net name).

If the certificate does not cover the name, CloudFront refuses to add the alternate domain name, and browsers would show certificate errors.

Q5. What is a CloudFront response headers policy? Fresher

A response headers policy adds or changes headers in responses that CloudFront sends to viewers, without changing the origin.

Common uses:

  • Security headers: Strict-Transport-Security (HSTS), X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Content-Security-Policy.
  • CORS headers for browser requests from other origins.
  • Custom headers such as Cache-Control overrides for browsers, or removing headers that reveal server details.

AWS provides managed policies (for example SecurityHeadersPolicy), and you attach a policy per cache behaviour.

Q6. What is the difference between CloudFront standard logs and real-time logs? Fresher
PointStandard logsReal-time logs
DeliveryDelivered in batches, minutes laterWithin seconds, to a Kinesis data stream
DestinationsS3, CloudWatch Logs or Firehose (newer logging options)Kinesis Data Streams
Fields and samplingFixed or selected fields, all requestsChoose fields and a sampling rate
CostLowKinesis and real-time log charges

Use standard logs for analytics and audits, and real-time logs for live dashboards and fast detection of errors or attacks.

Q7. What is CloudFront KeyValueStore? Fresher

CloudFront KeyValueStore is a small, globally replicated key-value data store that CloudFront Functions can read at the edge.

Uses:

  • Redirect tables (old path to new path) without redeploying code.
  • Feature flags and A/B test weights.
  • Allow or deny lists for simple access rules.

You update keys through the API, and functions read them with low latency. It suits small, read-heavy data, not large datasets.

Q8. What does turning on compression in a cache policy do? Fresher

With compression enabled (and the viewer sending Accept-Encoding), CloudFront can serve gzip or Brotli compressed versions of text files such as HTML, CSS, JavaScript and JSON.

  • Fewer bytes are sent, so pages load faster and data transfer costs fall.
  • The compression format becomes part of the cache key handling, so compressed and uncompressed versions are cached separately.
  • CloudFront compresses files in a certain size range; very small and very large files are not compressed by CloudFront itself.

Images and videos are already compressed, so they gain little.

Q9. An S3 REST origin returns 403 for /docs/ even though /docs/index.html exists. How do you fix it at the edge? Fresher

The default root object only works for the root path (/), not for sub-folders. With an S3 REST origin (behind OAC), a request for /docs/ asks for an object named "docs/", which does not exist.

Fix with a CloudFront Function on viewer request:

Output:

function handler(event) {
  var r = event.request;
  if (r.uri.endsWith('/')) { r.uri += 'index.html'; }
  else if (!r.uri.includes('.')) { r.uri += '/index.html'; }
  return r;
}

/docs/ becomes /docs/index.html before CloudFront looks in the cache or the origin.

Q10. What does the "allowed HTTP methods" setting on a cache behaviour control? Fresher

It decides which methods CloudFront accepts and forwards for that path:

  • GET, HEAD: static content.
  • GET, HEAD, OPTIONS: static content with CORS preflight.
  • GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE: APIs and forms.

CloudFront caches only GET and HEAD responses (and optionally OPTIONS). Other methods always go to the origin. If a behaviour for /api/* only allows GET and HEAD, POST requests get a 403 from CloudFront.

Q11. What does the "Age" of a cached object and the minimum TTL setting mean for freshness? Fresher
  • CloudFront keeps an object at the edge for a TTL decided by the origin's Cache-Control or Expires headers, bounded by the cache policy's minimum and maximum TTL.
  • If the origin says max-age=0 but the minimum TTL is 60 seconds, CloudFront still caches for 60 seconds.
  • The Age response header shows how many seconds the response has been in the cache.
  • Objects can be evicted earlier if they are rarely requested.

For pages that must update quickly, keep minimum TTL at 0 and control caching with origin headers.

Q31. How do you test whether a role is allowed an action with iam simulate-principal-policy? Fresher
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:role/app-role --action-names s3:GetObject s3:DeleteObject --resource-arns arn:aws:s3:::shop-data-111122223333/reports/a.csv --query "EvaluationResults[].[EvalActionName,EvalDecision]" --output text

Output:

s3:GetObject     allowed
s3:DeleteObject  implicitDeny

The role's identity policies allow reading but not deleting. "implicitDeny" means nothing allowed it; "explicitDeny" means a Deny statement matched.

Limits: the simulator does not fully evaluate every policy type (for example some resource-based policies and SCP details), so confirm important cases with a real test in a sandbox.

Q32. Why is aws sts get-caller-identity the first command to run when debugging access problems? Fresher
aws sts get-caller-identity

Output:

{"UserId": "AROA3XFRBF23EXAMPLE:ravi", "Account": "111122223333", "Arn": "arn:aws:sts::111122223333:assumed-role/dev-admin/ravi"}

The CLI is using the dev-admin role in account 111122223333, as session "ravi".

Many "AccessDenied" problems are simply the wrong profile, account or role (environment variables overriding the profile, an expired SSO session, or a container using the node role instead of its own). Confirm who you are before changing any policy.

Q33. What is a session policy? Fresher

A session policy is an optional policy you pass when you assume a role (or federate). The session's permissions become the intersection of the role's identity policies and the session policy.

aws sts assume-role --role-arn arn:aws:iam::111122223333:role/data-reader --role-session-name job-77 --policy file://only-one-prefix.json

Use it to give a short-lived session less than the role allows, for example a job that should only read one S3 prefix. A session policy can never add permissions the role does not have.

Q34. What are IAM policy variables, and give an example? Fresher

Policy variables are placeholders that IAM fills in at request time, so one policy works for many users or sessions.

Output:

"Resource": "arn:aws:s3:::team-files-111122223333/${aws:PrincipalTag/team}/*"

Each principal can only access the folder named after its team tag.

Other common variables: ${aws:username}, ${aws:userid}, ${aws:PrincipalTag/key}, ${aws:SourceIdentity}. They make ABAC-style policies short and avoid one policy per user.

Q35. How do you check a policy for errors and risky patterns before using it? Fresher

Use IAM Access Analyzer policy validation:

aws accessanalyzer validate-policy --policy-type IDENTITY_POLICY --policy-document file://policy.json --query "findings[].[findingType,issueCode]" --output text

Output:

SECURITY_WARNING  PASS_ROLE_WITH_STAR_IN_RESOURCE
SUGGESTION        EMPTY_ARRAY_CONDITION

The policy allows iam:PassRole on all roles (risky), and a condition is empty. Findings are errors, security warnings, warnings and suggestions with links to fixes.

Run it in CI for every policy change.

Q36. Why can an AWS managed policy be risky to depend on in production? Fresher
  • AWS can update AWS managed policies (for example adding new actions when services launch features). Your roles may gain new permissions without any change by you.
  • Many AWS managed policies are broad (for example full access to a service).
  • You cannot edit them; you can only attach or detach.

Use them for quick starts and job-function roles, but for applications write customer managed policies with only the needed actions and resources, and review changes with version control.

Q51. What are the three ways Lambda gets invoked, and how do errors behave in each? Fresher
ModelExamplesOn error
SynchronousAPI Gateway, ALB, function URL, SDK invokeError goes straight back to the caller; the caller decides to retry
AsynchronousS3 events, SNS, EventBridgeLambda queues the event and retries (by default twice), then sends it to a destination or DLQ
Event source mapping (poll-based)SQS, Kinesis, DynamoDB Streams, KafkaLambda's poller retries the batch; behaviour depends on source (SQS visibility timeout and DLQ, streams retry until success or expiry)

Knowing the model tells you where failed events go and who must handle retries.

Q52. What happens during a Lambda cold start, and which code runs in each phase? Fresher
  • Init phase: Lambda creates an execution environment, downloads your code or image, starts the runtime and extensions, and runs code outside the handler (imports, SDK clients, configuration loading).
  • Invoke phase: the handler runs for the event.
  • The environment is then kept warm for a while and reused for later requests, so init code does not run again.

Tips: put expensive setup (clients, connections) outside the handler so it runs once; keep packages small; lazy-load rarely used libraries; and remember that each concurrent request needs its own environment, so traffic spikes cause new cold starts.

Q53. How do you publish a Lambda layer and attach it to a function? Fresher
aws lambda publish-layer-version --layer-name pandas-py312 --zip-file fileb://layer.zip --compatible-runtimes python3.12 --compatible-architectures arm64

Output:

{"LayerVersionArn": "arn:aws:lambda:ap-south-1:111122223333:layer:pandas-py312:3", "Version": 3}
aws lambda update-function-configuration --function-name report-builder --layers arn:aws:lambda:ap-south-1:111122223333:layer:pandas-py312:3

version 3 of the layer is attached. Layers are versioned and immutable; functions keep using the version they reference until you update them. A function can use up to five layers, and the total unzipped size (function plus layers) has a limit.

Q54. For failed async Lambda events, when would you pick on-failure destinations over a DLQ, and what extra data do you get? Fresher
PointDLQDestinations
Used forFailed asynchronous invocationsSuccessful and failed async invocations; failures for some event source mappings
TargetsSQS or SNSSQS, SNS, Lambda, EventBridge (and S3 for some failure cases)
ContentOriginal event onlyEvent plus details: error message, stack trace, response, request context

Prefer on-failure destinations for new designs because they carry more information. Use on-success destinations to trigger the next step without writing that call in your code.

Q55. A Lambda function in a VPC times out when calling an external API. Why? Fresher

When a function is attached to a VPC, it uses network interfaces in your private subnets. Those subnets have no public IP route, so the function cannot reach the internet unless:

  • The subnets route 0.0.0.0/0 to a NAT gateway (in a public subnet), or
  • The function calls AWS services through VPC endpoints instead.

Also check the function's security group allows outbound traffic. Putting a Lambda function in a public subnet does not help, because Lambda ENIs never get public IPs. Only attach functions to a VPC when they need private resources.

Q56. How do you estimate the concurrency a Lambda function needs? Fresher

Concurrency is roughly requests per second x average duration in seconds.

Example only: 200 requests per second x 0.5 seconds = 100 concurrent executions.

  • If duration doubles because a database slows down, concurrency doubles too, even with the same traffic.
  • Compare the estimate with the account's concurrency quota for the Region and any reserved concurrency on the function.
  • For SQS and stream sources, concurrency also depends on batch settings and shard counts.

Watch ConcurrentExecutions in CloudWatch, and alarm before you reach the limit.

Q57. What happens when a function hits its concurrency limit, for synchronous and asynchronous calls? Fresher
  • Synchronous: Lambda returns a throttling error (429 TooManyRequestsException). The caller must retry; API Gateway returns an error to the client.
  • Asynchronous: Lambda keeps the event in its internal queue and retries for up to the maximum event age (up to 6 hours by default), then sends it to the failure destination or DLQ.
  • SQS event source: Lambda reduces polling; messages wait in the queue and become visible again after the visibility timeout.

So throttling loses requests for synchronous callers that do not retry, but usually only delays asynchronous and queue-based work.

Q71. What is single-table design in DynamoDB, and why do people use it? Fresher

Single-table design stores several entity types (customers, orders, order items) in one table, using generic key names (PK, SK) and key patterns such as PK = CUSTOMER#42, SK = ORDER#2026-11-20#501.

Why:

  • One Query can fetch related items together (a customer and their recent orders), which replaces joins.
  • Fewer tables to manage, monitor and back up.

Costs: harder to understand, needs careful planning of access patterns, and analytics tools find it harder to read. It is a tool, not a rule; several tables are fine when entities are not read together.

Q72. How do you use a sort key to model hierarchical data in DynamoDB? Fresher

Build the sort key from levels, from general to specific:

Output:

PK = COUNTRY#IN, SK = MH#MUMBAI#ANDHERI#STORE-17

Then one Query with begins_with answers several questions:

  • All stores in Maharashtra: begins_with(SK, "MH#")
  • All stores in Mumbai: begins_with(SK, "MH#MUMBAI#")
aws dynamodb query --table-name Stores --key-condition-expression "PK = :pk AND begins_with(SK, :p)" --expression-attribute-values '{":pk":{"S":"COUNTRY#IN"},":p":{"S":"MH#MUMBAI#"}}'

Order of levels matters: you can only filter efficiently from the left side of the sort key.

Q73. What is a sparse index in DynamoDB? Fresher

A GSI only contains items that have the index's key attributes. If only some items have the attribute, the index is "sparse" and much smaller than the table.

Example: add an attribute open_since only to orders that are still open. A GSI on open_since then contains only open orders, so "list open orders older than one hour" is a small, cheap query. When an order closes, remove the attribute and the item disappears from the index.

It is a cheap way to keep a "to-do list" view of a large table.

Q74. What limit applies to tables that have a local secondary index? Fresher

With an LSI, all items with the same partition key value (in the table and its LSIs) form an item collection, and an item collection cannot grow beyond 10 GB.

If a customer's partition grows past that, writes for that partition key fail (ItemCollectionSizeLimitExceededException).

Also, LSIs must be created with the table and cannot be added later. For partitions that can grow without limit, use a GSI instead, or design the key so each partition stays small (for example add a time bucket).

Q75. How do you page through DynamoDB query results correctly? Fresher

DynamoDB returns at most 1 MB of data per Query or Scan call. If there is more, the response includes LastEvaluatedKey.

aws dynamodb query --table-name Orders --key-condition-expression "PK = :c" --expression-attribute-values '{":c":{"S":"CUSTOMER#42"}}' --limit 20

Output:

{"Count": 20, "LastEvaluatedKey": {"PK": {"S": "CUSTOMER#42"}, "SK": {"S": "ORDER#2026-10-02#311"}}}

Pass it back as ExclusiveStartKey in the next request. The CLI paginates automatically unless you use --no-paginate or --max-items. Note that Limit counts items read before filters, so a filtered page may return fewer items.

Q76. Why must code check UnprocessedItems after BatchWriteItem? Fresher

BatchWriteItem can succeed overall but leave some items unwritten (for example due to throttling). Those come back in UnprocessedItems.

Output:

{"UnprocessedItems": {"Orders": [{"PutRequest": {"Item": {...}}}]}}

If code ignores this, data is silently lost. Retry the unprocessed items with exponential backoff until none remain. The AWS SDKs' higher-level helpers (for example batch writers) do this for you. BatchGetItem has the same pattern with UnprocessedKeys.

Q77. An item is getting close to the 400 KB size limit. What are your options? Fresher
  • Store large attributes (documents, images, long text) in S3 and keep only the S3 key and metadata in the item.
  • Split the item into several items with the same partition key and different sort keys (for example ORDER#501#HEADER, ORDER#501#ITEM#1).
  • Compress large text attributes (gzip) before storing, and decompress in the application.
  • Remove attributes that are not needed, or move history out of the item.

Large items also cost more to read and write (capacity is per KB), so smaller items save money too.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q12. Should you block countries with CloudFront geographic restrictions or with an AWS WAF geo match rule? Mid level
PointCloudFront geo restrictionWAF geo match rule
ScopeWhole distributionPer rule, can combine with paths, headers, rate limits
ModeAllow list or block list of countriesBlock, allow, count or CAPTCHA
LoggingStandard logs show 403WAF logs with rule details
CostIncludedWAF charges

Pick CloudFront geo restriction for simple "this content is only for India" rules. Pick WAF when you need exceptions (for example allow /status from anywhere) or want to count first. Geo detection is based on IP databases and is not perfect (VPNs, proxies).

Q13. How do you create a CloudFront signed URL from the CLI for testing? Mid level
aws cloudfront sign --url https://media.shop.example.com/videos/intro.mp4 --key-pair-id K2JCJMDEHXQW5F --private-key file://private_key.pem --date-less-than 2026-11-21T00:00:00Z

Output:

https://media.shop.example.com/videos/intro.mp4?Expires=1763683200&Signature=...&Key-Pair-Id=K2JCJMDEHXQW5F

The URL works until the expiry time, if the behaviour trusts the key group that contains that public key ID.

In production, your application signs URLs with an SDK after checking the user is allowed. Keep the private key in Secrets Manager and short expiry times.

Q14. What is the difference between a canned policy and a custom policy for signed URLs and cookies? Mid level
PointCanned policyCustom policy
ExpiryOnly an end timeEnd time and optional start time
IP restrictionNoOptional source IP range
ResourceOne exact URLCan use wildcards (for example /videos/course-12/*)
URL lengthShorterLonger (policy is included, base64 encoded)

Pick canned for simple single-file links. Pick custom policies (usually with signed cookies) for access to a whole folder, such as all segments of a video stream.

Q15. CloudFront returns 504 Gateway Timeout for some requests. What do you check? Mid level

504 means CloudFront could not get a response from the origin in time.

  • Origin response timeout (default 30 seconds) vs how long the origin really takes; slow reports or uploads may need a longer timeout or an async design.
  • Origin connection attempts and connection timeout settings.
  • Origin health: ALB target errors, Lambda timeouts, overloaded instances.
  • Network path: security groups or NACLs blocking CloudFront IP ranges (use the managed prefix list), or the origin only reachable privately (use VPC origins).
  • TLS problems usually show as 502, not 504.

Check CloudFront logs for x-edge-detailed-result-type and timing fields, and the origin's own logs at the same time.

Q16. How can one distribution serve several domains, each with HTTPS? Mid level
  • Add all names as alternate domain names on the distribution.
  • Attach one ACM certificate (in us-east-1) that covers all of them, using Subject Alternative Names or wildcards, for example shop.example.com, www.shop.example.com and *.shop.example.com.
  • CloudFront uses SNI to present the certificate; all modern browsers support it.
  • Use cache behaviours or a function on the Host header if different domains need different origins or paths, and include Host in the cache key only when content differs by domain.

For many customer domains, see the multi-tenant question below.

Q17. What is a CloudFront staging distribution used for? Mid level

CloudFront continuous deployment lets you create a staging distribution with a copy of the production configuration, change it, and send part of the traffic to it:

  • Weight-based: a small percentage of viewer requests go to staging.
  • Header-based: only requests with a specific header (for testers) go to staging.

If the new configuration works, promote it to the primary distribution; if not, remove the policy. This makes configuration changes (new cache policies, functions, origins) much safer than editing production directly.

Q18. How do you invalidate large numbers of files efficiently, and what limits apply? Mid level
  • Prefer versioned file names (app.4f2c.js) so most deploys need no invalidation.
  • Use wildcard paths (/images/products/*) instead of listing thousands of single paths; each wildcard counts as one path for billing.
  • CloudFront limits how many invalidation paths can be in progress at the same time (wildcards have their own lower limit); large batches queue or fail, so batch them.
  • Invalidating /* clears everything and sends a burst of traffic to the origin.

Check the current quotas in the CloudFront documentation before automating big invalidations.

Q19. Where do Lambda@Edge logs go, and why can't you find them? Mid level

Lambda@Edge functions run in AWS Regions close to the edge location that handled the request. Their logs go to CloudWatch Logs in that Region, in a log group named like /aws/lambda/us-east-1.my-edge-function.

So if most users are in India, the logs may be in ap-south-1, not us-east-1 where you created the function.

Tips: check several Regions, use the CloudFront console's Lambda@Edge monitoring links, and aggregate logs centrally with subscription filters.

Q20. Can CloudFront carry WebSocket connections, and what do you configure? Mid level

Yes. CloudFront supports WebSocket connections over HTTP/1.1 upgrade.

  • The behaviour must forward the required headers (Sec-WebSocket-Key, Sec-WebSocket-Version and related) through an origin request policy, or use a policy that forwards all viewer headers.
  • Allow the needed methods and do not cache the path (CachingDisabled).
  • The origin (ALB, API Gateway WebSocket API or a custom server) must support WebSockets.
  • Connection idle and keep-alive settings at the origin matter for long-lived connections.

Benefits: one domain for the site and real-time features, plus edge TLS and WAF.

Q21. Why does a short origin outage cause users to see errors for longer than the outage? Mid level

CloudFront caches error responses (such as 500, 502, 503, 504 and 404) for an error caching minimum TTL, which by default is several seconds and can be configured per error code.

So after the origin recovers, users can still get the cached error until that TTL expires.

Options:

  • Set a lower error caching TTL for 5xx errors (for example 0 to a few seconds).
  • Use a custom error response to show a friendly page.
  • Use an origin group so CloudFront fails over to a secondary origin.

Set a longer error TTL for 404s on static sites to protect the origin from repeated misses.

Q22. What is CloudFront field-level encryption? Mid level

Field-level encryption encrypts specific fields of a POST request (for example card number or national ID) at the edge, using a public key you provide. Only the backend system holding the private key can decrypt them.

Result: even if other layers (load balancers, logs, intermediate services) see the request, those fields stay encrypted end to end.

Use it for sensitive form fields that only one internal service should read. Many teams instead send such data directly to a payment provider's tokenisation service.

Q37. Walk through how IAM decides whether a request inside one account is allowed. Mid level

Simplified order:

1. Start with deny by default.

2. If any applicable policy has an explicit Deny that matches, the result is Deny (identity, resource, SCP, RCP, boundary or session policy).

3. Organizations SCPs (and RCPs for resources) must allow the action, or it is denied.

4. Resource-based policy: in the same account, an Allow here can grant access on its own for many services (with nuances for roles and boundaries).

5. Identity-based policies must allow it, and a permissions boundary (if set) must also allow it.

6. Session policies (if used) must also allow it.

Remember: only identity-based and resource-based policies grant; SCPs, RCPs, boundaries and session policies only limit.

Q38. Why are NotAction and NotResource dangerous in an Allow statement? Mid level

"Effect": "Allow", "NotAction": "iam:*" means "allow every action except IAM", including every service AWS launches in future, not "deny IAM".

Risks: gives far more than intended, and it is easy to misread in reviews.

Safer uses:

  • NotAction in Deny statements, for example deny everything except a short list of global services outside approved Regions.

Prefer explicit Action lists in Allow statements, and use Access Analyzer validation to flag broad allows.

Q39. A role's identity policy allows ec2:* and its permissions boundary allows s3:* only. What can the role do? Mid level

Nothing with EC2 or S3 based on identity policies alone. For identity-based permissions, the effective permissions are the intersection of the identity policy and the boundary.

  • ec2:*: allowed by the identity policy, but not by the boundary, so denied.
  • s3:*: allowed by the boundary, but not by the identity policy, so denied.

The boundary sets the maximum; it never grants. To allow S3 reads, add them to the identity policy too. This is why boundaries are often written as broad maximums ("anything except IAM admin and these sensitive services").

Q40. How do you test a new SCP before attaching it to production accounts? Mid level
  • Write it as a deny-list SCP with clear Sid names and conditions.
  • Attach it first to a test OU with sandbox accounts that mirror production roles and pipelines.
  • Run the main workflows (deployments, break-glass access, backups, log delivery) and watch CloudTrail for AccessDenied events with the SCP named in the error context.
  • Check exceptions for automation roles and AWS service-linked behaviour.
  • Roll out to non-production OUs, then production, with a rollback plan (a management account role that can detach the SCP).

Never test SCPs first on the root of the organisation.

Q41. How can CI block IAM policy changes that grant new access? Mid level

Use IAM Access Analyzer custom policy checks in the pipeline:

  • check-no-new-access: compares the new policy with the current one and fails if it grants new permissions, so reviewers must approve.
  • check-access-not-granted: fails if the policy grants listed sensitive actions (for example iam:CreateUser or kms:Decrypt on all keys) or access to listed resources.
  • check-no-public-access: fails if a resource policy allows public access.
aws accessanalyzer check-access-not-granted --policy-document file://policy.json --access '[{"actions":["iam:PassRole"]}]' --policy-type IDENTITY_POLICY

Output:

{"result": "FAIL", "message": "The policy document grants access to perform one or more of the listed actions."}

These checks use automated reasoning and are billed per call.

Q42. What is role chaining, and what limit does it add? Mid level

Role chaining is when a session from one assumed role assumes another role (role A to role B), for example a CI role in a tools account assuming a deploy role in production.

Limits and points:

  • A chained session lasts at most one hour, even if the target role's maximum session duration is longer.
  • Session tags can be passed and made transitive so they carry through the chain.
  • CloudTrail shows each AssumeRole; use sts:SourceIdentity so the original person is visible at every hop.

If jobs need longer sessions, avoid chaining: assume the final role directly from the original identity.

Q43. How does the aws:PrincipalOrgID condition help in resource policies? Mid level

It lets a resource trust every principal in your AWS Organization without listing account IDs:

Output:

"Condition": {"StringEquals": {"aws:PrincipalOrgID": "o-a1b2c3d4e5"}}

Only principals from accounts in that organisation can use the resource (a bucket, KMS key, SNS topic, VPC endpoint).

Benefits: new accounts work automatically, and accounts that leave the organisation lose access. Related keys: aws:PrincipalOrgPaths (restrict to OUs) and aws:ResourceOrgID (restrict which resources your principals can reach), used together in data perimeters.

Q45. An on-premises server needs AWS access without long-term access keys. What do you use? Mid level

IAM Roles Anywhere:

  • Set up a trust anchor based on your private certificate authority (AWS Private CA or your own CA).
  • Create a profile that maps to one or more IAM roles, with optional conditions on certificate attributes.
  • The server uses its X.509 certificate with the credential helper to get temporary AWS credentials.
aws_signing_helper credential-process --certificate server.pem --private-key server.key --trust-anchor-arn arn:aws:rolesanywhere:ap-south-1:111122223333:trust-anchor/ta-1 --profile-arn arn:aws:rolesanywhere:ap-south-1:111122223333:profile/p-1 --role-arn arn:aws:iam::111122223333:role/onprem-backup

Result: credentials expire automatically, and you revoke access by revoking the certificate.

Q58. How do you configure provisioned concurrency on an alias and scale it on a schedule? Mid level
aws lambda put-provisioned-concurrency-config --function-name checkout --qualifier live --provisioned-concurrent-executions 50
aws application-autoscaling register-scalable-target --service-namespace lambda --resource-id function:checkout:live --scalable-dimension lambda:function:ProvisionedConcurrency --min-capacity 10 --max-capacity 200

Then add a scheduled action (for example 150 from 09:00 to 21:00 IST) or a target tracking policy on ProvisionedConcurrencyUtilization.

Requests to the live alias land on pre-initialised environments, so they avoid cold starts. Provisioned concurrency is set on a version or alias, never on $LATEST, and it is billed while configured.

Q59. What is Lambda SnapStart, and what must your code handle? Mid level

SnapStart takes a snapshot of the initialised execution environment when you publish a version, and later resumes new environments from that snapshot. This greatly reduces cold start time, especially for Java. It is available for Java, Python and .NET runtimes (pricing differs by runtime; check current docs).

Code must handle restore correctly:

  • Unique values generated during init (random seeds, IDs) would be shared by all restored environments; regenerate them after restore (runtime hooks).
  • Network connections created during init may be stale after restore; reconnect.
  • Credentials or time-based values cached at init may be old.

It works on published versions and aliases, not $LATEST.

Q60. Which settings control how Lambda reads from an SQS queue? Mid level
  • Batch size: how many messages per invocation.
  • Batching window: how long Lambda waits to fill a batch (up to 5 minutes), trading latency for fewer invocations.
  • Maximum concurrency: caps how many concurrent functions this event source uses, protecting downstream systems without using reserved concurrency.
  • Report batch item failures: only failed messages return to the queue.
  • Queue settings matter too: visibility timeout should be at least six times the function timeout (AWS guidance), and a DLQ with a maxReceiveCount.
aws lambda update-event-source-mapping --uuid 1a2b3c4d-5678-90ab-cdef-11112222abcd --batch-size 50 --maximum-batching-window-in-seconds 10 --scaling-config MaximumConcurrency=20
Q61. What does the parallelization factor do for a Kinesis or DynamoDB Streams event source? Mid level

By default, Lambda processes one batch per shard at a time, so throughput is limited by the number of shards.

The parallelization factor (1 to 10) lets Lambda process several batches from the same shard at once, while still keeping order for records with the same partition key.

Use it when consumers fall behind (IteratorAge grows) but adding shards is expensive or slow. Combine with bisect-on-error, maximum retry attempts, maximum record age and an on-failure destination so one bad record does not block a shard.

Q62. How do event filters on an event source mapping save cost? Mid level

You can add filter criteria so Lambda only invokes your function for matching records:

Output:

{"Filters": [{"Pattern": "{\"body\": {\"type\": [\"ORDER_PLACED\"]}}"}]}

Only SQS messages whose JSON body has type ORDER_PLACED invoke the function.

Records that do not match are dropped (for SQS, they are deleted from the queue; for streams, skipped), so make sure no other consumer needs them. Filtering before invocation avoids paying for invocations that would just ignore the event.

Q63. How do you change Lambda's retry behaviour for asynchronous invocations? Mid level
aws lambda put-function-event-invoke-config --function-name send-email --maximum-retry-attempts 1 --maximum-event-age-in-seconds 3600 --destination-config '{"OnFailure":{"Destination":"arn:aws:sqs:ap-south-1:111122223333:email-failures"}}'

Lambda retries a failed event once, discards events older than one hour, and sends failures to an SQS queue with error details.

Lower retries for non-idempotent actions (sending emails or SMS) to avoid duplicates; keep retries and longer ages for important, idempotent work.

Q65. How is Lambda billed beyond requests and duration? Mid level

Main charges (mechanics, not rates):

  • Requests: per million invocations.
  • Duration: GB-seconds (memory x time), with a lower price per GB-second on arm64.
  • Provisioned concurrency: billed for the configured concurrency for as long as it is configured, plus a duration charge for requests that use it.
  • Ephemeral storage above the default 512 MB.
  • Data transfer out, and charges from other services (CloudWatch Logs ingestion, NAT gateway, API Gateway).
  • SnapStart caching and restore charges for some runtimes.

Log ingestion and NAT often surprise teams more than Lambda itself.

Q78. How does write sharding fix a hot partition key, and what does it cost on reads? Mid level

If one key (for example the date 2026-11-20 for all events today) gets too many writes, add a suffix to spread writes:

Output:

PK = EVENTS#2026-11-20#7   (suffix 0-9 chosen by hash of the event ID or at random)

Writes now spread over 10 keys.

Cost: to read all events for the day, you query all 10 keys (in parallel) and merge results. A calculated suffix (from a hash of a known attribute) lets you find one specific item directly. Choose the number of shards from the write rate per key that DynamoDB can sustain.

Q80. How do you query DynamoDB by status and date range efficiently? Mid level

Use a composite sort key that combines both, in the order you filter:

Output:

GSI1PK = CUSTOMER#42, GSI1SK = SHIPPED#2026-11-20T10:15:00Z

Query: GSI1PK = CUSTOMER#42 AND GSI1SK BETWEEN "SHIPPED#2026-11-01" AND "SHIPPED#2026-11-30"

The customer's shipped orders in November, without a filter expression reading unrelated items.

The first part (status) must be an exact match; the range works on the last part. If you also need "all orders in a date range regardless of status", that needs a different key or index.

Q81. How do you keep a version history of an item in DynamoDB? Mid level

A common pattern:

  • Each version is a separate item: SK = V1, V2, V3 ...
  • A special item SK = V0 always holds a copy of the latest version and a current version number.
  • An update writes the new version item and updates V0 in one transaction, with a condition that V0's version number has not changed (optimistic locking).

Reads of the current state get V0; audits query all versions. Old versions can be expired with TTL if history is only needed for a while.

Q82. What guarantees do DynamoDB Streams give, and how do you recognise TTL deletes in them? Mid level
  • Each item change appears once in the stream, in the order it happened for that item (ordering across different items is not guaranteed).
  • Records are kept for 24 hours; a consumer that is down longer loses records.
  • You choose the view type (keys only, new image, old image, or both).

TTL deletions appear as REMOVE events with a userIdentity of type "Service" and principal "dynamodb.amazonaws.com", so consumers can tell expiry deletes apart from user deletes, for example to archive expired items to S3 but ignore manual deletes.

Q83. What is multi-Region strong consistency in DynamoDB global tables? Mid level

By default, global tables use asynchronous replication with last-writer-wins conflict resolution: each Region accepts writes, and replicas are eventually consistent.

DynamoDB also offers a multi-Region strong consistency (MRSC) mode for global tables: writes are replicated synchronously across Regions so strongly consistent reads in any Region see the latest committed write.

Trade-offs: higher write latency, specific Region configurations (check the current documentation for supported setups and features), and conflicting concurrent writes fail rather than silently overwrite. Choose it for data where reading stale values in another Region is not acceptable.

Q84. How do you model a many-to-many relationship, such as students and courses, in DynamoDB? Mid level

Use the adjacency list pattern:

  • Item for each enrolment with PK = STUDENT#7, SK = COURSE#AWS101 (plus attributes like grade).
  • A GSI that flips the keys: GSI1PK = COURSE#AWS101, GSI1SK = STUDENT#7.

Then:

  • Courses of a student: Query PK = STUDENT#7, begins_with(SK, "COURSE#").
  • Students in a course: Query the GSI with GSI1PK = COURSE#AWS101.

Copy the few attributes you show in lists (course name, student name) into the enrolment item, so lists need no extra reads.

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q23. After an invalidation of /*, the origin crashed under load. How do you prevent this next time? Senior

All edge caches missed at once, so every request went to the origin.

Prevention:

  • Never invalidate everything as a routine step; use versioned assets and invalidate only HTML.
  • Turn on Origin Shield in the Region closest to the origin, so one cache layer collapses many misses into fewer origin requests.
  • Stagger invalidations in batches and deploy outside peak hours.
  • Make the origin scale (auto scaling, caching at the origin, S3 for static files).
  • Use stale content options: origins can send stale-while-revalidate and stale-if-error so CloudFront serves old copies briefly.
Q24. How would you run an A/B test of a new home page at the edge? Senior
  • A CloudFront Function on viewer request checks a cookie (ab=A or B). If missing, it assigns a group (for example 10% B, weights read from KeyValueStore) and rewrites the URI to /index-b.html for group B.
  • A function on viewer response sets the cookie so the user stays in the same group.
  • Include the cookie in the cache key only if the content differs, or better, rewrite the URI so the cache key is the path itself.
  • Analytics record the group from the cookie.

Benefits: no origin changes, sub-millisecond decisions, and quick rollback by changing the weights.

Q25. A video platform may only stream films in licensed countries, and only to paying users. How do you design delivery? Senior
  • Geo restriction (or WAF geo rules) on the video behaviour, allowing only licensed countries.
  • Signed cookies with a custom policy for the film's folder (all HLS or DASH segments), issued by the app after checking payment and licence region, with short expiry.
  • Private S3 origin with OAC; no public bucket access.
  • Optional DRM for premium content, because signed URLs control access but not copying.
  • Logs and alarms for unusual download patterns (scraping, shared cookies).

Remember that IP-based country detection can be bypassed with VPNs, so licence teams should know its limits.

Q26. Should you put CloudFront in front of an API Gateway API, and which endpoint type do you use? Senior
  • An edge-optimized API Gateway endpoint already uses an AWS-managed CloudFront distribution, but you cannot control its cache, WAF or behaviours.
  • A regional endpoint behind your own CloudFront distribution gives full control: custom cache policies for some GET routes, WAF at the edge, one domain for site and API, and Lambda@Edge or functions if needed.
  • Do not put your own CloudFront in front of an edge-optimized endpoint, because requests would pass through two CloudFront layers.

Also restrict the API so it only accepts traffic from your distribution (for example a secret header checked by a resource policy or WAF).

Q27. Users get 403 from CloudFront for some files but not others. How do you narrow it down? Senior
  • Read the response: x-cache and the body. "Error from cloudfront" vs an S3 XML AccessDenied body tells you whether CloudFront or the origin said no.
  • CloudFront-generated 403: WAF block, geo restriction, missing or expired signature on a behaviour that requires signed URLs, or a method not allowed.
  • Origin 403 from S3: object missing (with no ListBucket permission S3 returns 403), key case or encoding differences, KMS key policy not allowing the CloudFront service principal, or bucket policy not matching the distribution ARN.
  • Compare a working and a failing path: which behaviour do they match, and is there a different origin or policy?
Q28. How do you serve large file downloads (several GB) efficiently through CloudFront? Senior
  • CloudFront supports range requests: download managers and video players fetch byte ranges, which CloudFront caches in parts.
  • Origin: S3 is ideal; make sure it supports ranges (S3 does).
  • Use long TTLs and versioned file names for installers or datasets.
  • Turn on Origin Shield to reduce repeated fetches of large objects from many edges.
  • Protect paid downloads with signed URLs that expire.
  • Watch cost: data transfer out dominates; compression does not help already compressed files.
Q29. A SaaS company gives every customer a custom domain on CloudFront. How do you design it? Senior
  • Options: one distribution per customer (simple isolation, but limits and management overhead grow), or a multi-tenant setup where tenants share a configuration template. CloudFront has introduced multi-tenant distributions with tenant-specific domains and certificates for this use case; check current features and quotas.
  • Certificates: ACM certificates per tenant domain (validated by DNS records the customer adds), or managed certificate options in the multi-tenant feature.
  • Routing: the Host header identifies the tenant; functions or the origin map it to the tenant's data.
  • Automation: onboarding pipeline creates the tenant, validates the domain, and monitors certificate renewal.
  • Isolation: per-tenant WAF settings and rate limits where needed.
Q30. What is cache poisoning in CloudFront, and how do you prevent it? Senior

Cache poisoning happens when an attacker sends a request with an input that changes the response (for example a header like X-Forwarded-Host used to build links) but that input is not part of the cache key. CloudFront caches the harmful response and serves it to everyone.

Prevention:

  • Do not let the origin use headers, cookies or query strings that are not in the cache key to build responses; or include them in the cache key.
  • Forward only needed headers with origin request policies.
  • Normalise inputs in CloudFront Functions (lowercase, remove unexpected query strings).
  • Never cache responses that depend on user identity.
  • Test with security scanners that check for unkeyed inputs.
Q44. A policy denies requests unless aws:SourceIp is the office range, and now CloudFormation and Athena fail. Why? Senior

When an AWS service calls another service on your behalf (CloudFormation creating a bucket, Athena reading S3), the source IP is an AWS service address, not your office IP. The IP condition denies those calls.

Fix by excluding service calls:

Output:

"Condition": {"NotIpAddress": {"aws:SourceIp": "203.0.113.0/24"}, "Bool": {"aws:ViaAWSService": "false"}}

The deny applies only to direct calls from people or apps, not to calls that AWS services make for them. For traffic through VPC endpoints, aws:SourceVpc or aws:SourceVpce conditions are used instead of public IPs.

Q46. How would you design a data perimeter so company data can only be accessed by company identities from expected networks? Senior

Three layers, each answering one question:

  • Identity perimeter: resource policies and RCPs allow access only to principals in the organisation (aws:PrincipalOrgID), plus specific AWS services.
  • Resource perimeter: SCPs and VPC endpoint policies let company identities reach only company resources (aws:ResourceOrgID), stopping data copies to personal buckets.
  • Network perimeter: access to sensitive resources only from company VPCs or IP ranges (aws:SourceVpc, aws:SourceIp, with aws:ViaAWSService exceptions).

Roll out in stages with CloudTrail analysis of who would be blocked, and keep documented exceptions for partners and AWS services.

Q47. Which IAM permissions allow privilege escalation, and how do you detect them? Senior

Examples of permissions that let a user give themselves more power:

  • iam:CreatePolicyVersion or iam:SetDefaultPolicyVersion on a policy attached to them.
  • iam:AttachUserPolicy, iam:PutRolePolicy, iam:AttachRolePolicy on their own identity.
  • iam:PassRole on a powerful role plus permission to create EC2, Lambda or CloudFormation resources that use it.
  • iam:UpdateAssumeRolePolicy on an admin role.
  • iam:CreateAccessKey or iam:CreateLoginProfile for other users.

Detect: Access Analyzer validation and custom checks, open-source IAM scanners in CI, and GuardDuty or CloudTrail alerts for these calls. Prevent with permission boundaries and SCPs on sensitive IAM actions.

Q48. Design break-glass access for production accounts. Senior
  • A dedicated emergency role (or a small set of emergency users where SSO might fail), with strong MFA and credentials stored in a sealed process (for example split between two people).
  • SCPs exempt the break-glass role only from specific guardrails, not from logging.
  • Every use triggers alerts (EventBridge on AssumeRole or ConsoleLogin for that role) to security and management.
  • Sessions are short; actions are reviewed afterwards.
  • Test it on a schedule, because an emergency path that has never been used often fails when needed.
  • Remove standing admin access elsewhere, so break-glass is truly the exception.
Q49. An organisation-level Access Analyzer finds a role in production trusted by an unknown external account. How do you respond? Senior
  • Identify the role, the external account ID and when the trust was added (CloudTrail UpdateAssumeRolePolicy or CreateRole).
  • Check if the account belongs to a known vendor (contracts, vendor documentation) and whether ExternalId is required.
  • Check CloudTrail for AssumeRole calls from that account: has it been used, and what did the sessions do?
  • If unknown or not needed: remove the trust, revoke active sessions (deny older sessions with aws:TokenIssueTime), and treat it as a security incident.
  • If legitimate: archive the finding with a rule documenting why, and add conditions (ExternalId, source identity) if missing.
Q50. A role in account A reads a bucket in account B. The bucket policy allows the role, but access is denied. The role has a permissions boundary. What could be wrong? Senior

For cross-account access, both sides must allow: the bucket policy in B, and the role's identity-based permissions in A. A permissions boundary on the role limits the identity side.

Checks:

  • Does the role's identity policy allow s3:GetObject on that bucket ARN?
  • Does the boundary also allow it? If the boundary only allows resources in account A (for example a condition on aws:ResourceAccount), cross-account access is blocked.
  • SCPs in account A or RCPs in account B may deny it.
  • KMS: if objects use SSE-KMS, the key policy in B and the role's policy must allow kms:Decrypt.

Use CloudTrail in both accounts to see which side denied.

Q64. What should you plan when attaching many Lambda functions to a VPC? Senior
  • Lambda creates shared Hyperplane network interfaces per subnet and security group combination, not one per invocation, so IP use is modest; still give functions subnets with free IPs in at least two AZs.
  • Security groups: functions need outbound rules to their targets; targets (RDS, ElastiCache) must allow the function's security group.
  • Internet and AWS APIs: route through a NAT gateway or use VPC endpoints.
  • The first attachment or a change to subnets and security groups can take time while interfaces are created.
  • Changing a function's VPC settings is a deployment; test it like code.
Q66. A Java API on Lambda has cold starts of several seconds. What is your plan? Senior
  • Turn on SnapStart for the function versions behind the alias, and handle restore hooks.
  • Reduce init work: fewer dependencies, avoid heavy frameworks or use ones built for fast start, lazy initialisation.
  • Increase memory (more CPU speeds up JVM start), test with Power Tuning.
  • Use arm64 and a recent Java runtime.
  • For strict latency targets at known peak times, add provisioned concurrency with scheduled scaling.
  • Measure: Init Duration in logs and p99 latency at the API, before and after each change.

If cold starts still matter after all this, a container service may suit the API better.

Q67. Lambda reads from an SQS FIFO queue and processing is slower than expected. How does scaling work, and how do you speed it up? Senior

For FIFO queues, Lambda processes messages in order per message group. Only one batch per message group is in flight at a time, so concurrency is limited by the number of active message groups.

Speed-ups:

  • Use more message groups (for example per customer or order) so many groups are processed in parallel.
  • Keep processing per batch fast; slow handlers block their group.
  • Report partial batch failures carefully: in FIFO, a failure should stop later messages of that group from being processed out of order.
  • If strict ordering is not needed, a standard queue scales much further.
Q68. How do you design Lambda consumption from an Amazon MSK (Kafka) topic for high throughput? Senior
  • Event source mapping on the MSK cluster with the right authentication (IAM or SASL/SCRAM) and VPC connectivity (subnets and security groups that reach the brokers).
  • Partitions set the upper limit of parallelism; plan partition count for peak throughput.
  • Use provisioned mode for the event source mapping (a configurable minimum and maximum number of pollers) when you need predictable, high throughput and fast scaling.
  • Tune batch size and batching window; handle errors with an on-failure destination so a bad record does not block a partition.
  • Make processing idempotent, because Kafka delivery to Lambda is at least once.
Q69. A downstream payment API is down for an hour. How do you make sure no Lambda-driven events are lost? Senior
  • Put a queue between the event source and the function that calls the API (SQS), instead of direct asynchronous invocation with limited retry time.
  • Long message retention on the queue, a DLQ with a sensible maxReceiveCount, and on-failure destinations for async paths.
  • Use maximum concurrency on the event source mapping and backoff in code, so the function does not hammer the failing API.
  • A circuit breaker pattern: when the API fails repeatedly, stop calling it for a while.
  • Idempotency keys so retried calls do not double charge.
  • After recovery, redrive the DLQ at a controlled rate and alarm on queue age throughout.
Q70. After moving a Lambda function into a VPC, its calls to DynamoDB and S3 time out. How do you fix it properly? Senior

The function now uses private subnets without internet access, so the public DynamoDB and S3 endpoints are unreachable.

Proper fix:

  • Add gateway VPC endpoints for S3 and DynamoDB to the route tables of the function's subnets (no hourly cost).
  • Add interface endpoints for other services it calls (Secrets Manager, SQS, STS).
  • Check endpoint policies allow the needed actions and resources, and the security group allows outbound HTTPS.
  • Only add a NAT gateway if the function really needs the public internet.

Also lower the SDK timeouts so failures show quickly instead of using the whole function timeout.

Q79. What is GSI overloading? Senior

GSI overloading means one GSI serves several access patterns, because different item types put different meanings into the same generic index attributes (GSI1PK, GSI1SK).

Example:

  • Order items: GSI1PK = STATUS#SHIPPED, GSI1SK = 2026-11-20 (orders by status and date).
  • Customer items: GSI1PK = EMAIL#asha@example.com, GSI1SK = CUSTOMER (lookup by email).

Benefits: fewer indexes (each GSI adds write cost), and new patterns without new indexes. Cost: the design must be documented carefully, or the team will not understand what the index holds.

Q85. A checkout must update more than 100 items atomically, but DynamoDB transactions are limited. How do you design it? Senior

DynamoDB transactions can include up to 100 actions (and have a total size limit), so a huge cart cannot be one transaction.

Options:

  • Change the model: store the cart as one or a few items (line items as a list or in a few chunk items), so the order write is small.
  • Reserve stock per SKU in batches with conditional writes, and write the order last; if a step fails, release the reservations (a saga with compensating actions), orchestrated by Step Functions.
  • Make each step idempotent with request IDs.

Explain the trade-off: no single atomic commit, but correctness through conditions, compensation and idempotency.

Q86. The product team wants "number of orders per day and per store" from a DynamoDB table in real time. How do you provide it? Senior

DynamoDB has no GROUP BY, and counting with scans is slow and costly.

  • A stream consumer (Lambda) updates counter items on each new order: PK = STATS#STORE#17, SK = DAY#2026-11-20, using atomic ADD updates.
  • Make it idempotent (record processed order IDs, or derive counts carefully) because streams can deliver to Lambda more than once on retries.
  • For very hot counters, shard the counter items and sum on read.
  • For ad-hoc analytics, export to S3 (or zero-ETL to Redshift) and query there.

The dashboard reads a few counter items, which is fast and cheap.

Q87. How do you store high-volume time-series data in DynamoDB without one huge, hot table? Senior
  • Time-bucketed keys: PK = DEVICE#55#2026-11-20 so each day's data for a device is its own partition.
  • Table per period (for example one table per month): new data goes to the current table with high capacity; old tables get lower capacity or the Standard-IA table class, and can be exported to S3 and deleted.
  • TTL to delete old raw data automatically, with a stream consumer archiving to S3 first if needed.
  • Pre-aggregated items (hourly averages) for dashboards.

This keeps writes spread out and storage costs under control.

Q88. Two Regions update the same item in a global table at nearly the same time. What happens, and how do you design for it? Senior

With default (eventually consistent) global tables, both writes succeed locally, then replicate. Last writer wins based on timestamps, so one update silently overwrites the other in all Regions.

Design options:

  • Write each item in only one "home" Region (route users to their home Region), so conflicts are rare.
  • Model changes as separate items (append-only events) instead of updating one shared item.
  • Use atomic counters carefully: concurrent increments in two Regions can be lost.
  • Use multi-Region strong consistency mode where conflicts must fail instead of overwrite.
Q89. How do you choose the partition key for a multi-tenant SaaS table with tenants of very different sizes? Senior
  • Start with tenant-prefixed keys (TENANT#acme#ORDER#501) so every query is scoped to a tenant and IAM leading-key conditions can enforce isolation.
  • Avoid PK = TENANT#acme alone for big tenants, because one partition key would take all their traffic. Add a second level (TENANT#acme#USER#7 or a shard suffix) so large tenants spread across many partitions.
  • Keep per-tenant metrics (CloudWatch Contributor Insights) to spot hot tenants.
  • Move very large or regulated tenants to their own table or account if needed.
Q90. Design the DynamoDB table for a chat app: conversations, messages and "my recent conversations". Senior
  • Messages: PK = CONV#123, SK = MSG#2026-11-20T10:15:30.123Z#u7 (time-ordered; Query with ScanIndexForward false and Limit 50 for the latest page).
  • Membership and inbox: PK = USER#u7, SK = CONV#123 with last_message_at and a preview; a GSI or LSI on PK + last_message_at gives "recent conversations" sorted by activity.
  • On each new message, update the members' inbox items (a stream consumer can fan out to many members).
  • Large group chats: shard very busy conversations by time bucket.
  • TTL for disappearing messages; S3 for attachments with pointers in the message item.

5. Frequently asked questions

Which of the four is asked most in deep-dive rounds?

IAM and DynamoDB for backend and security roles, CloudFront for web and platform roles, and Lambda for serverless roles. Senior interviews usually touch all four.

How do I prepare for "design" questions on these services?

Practise explaining one request end to end: the CloudFront behaviour it matches, the IAM checks it passes, how Lambda scales for it, and the exact DynamoDB key it reads.

Are the numbers on this page fixed?

No. Quotas and features change. The page names well-known limits where they are stable; always check the current AWS documentation before relying on a number.

6. Quick revision

  • CloudFront: invalidate paths sparingly, prefer versioned file names; signed cookies for many files, signed URLs for one.
  • IAM: an explicit deny anywhere wins; boundaries, SCPs and session policies only limit, never grant.
  • Lambda: sync, async and poll-based invocations behave differently on errors and retries.
  • DynamoDB: design keys from access patterns; spread writes; streams keep 24 hours of ordered changes per item.

This page is one part of the complete AWS interview question set. Open the full list here: All 2052 AWS interview questions.