AWS DevOps Scenario Based Interview Questions: Find the Cause, Then Defend It

Branko Petric
Branko Petric

- 15 min read

The short answer

AWS scenario questions test whether you find the cause before you spend money or open access. Replace static keys with instance roles, debug S3 403s at the exact policy, move S3 and ECR traffic off NAT with endpoints, pool Lambda connections with RDS Proxy, and make SQS consumers idempotent. Then hold that position under pushback.

Most AWS interview question lists ask you to explain a service: what is CodePipeline, what is a NACL. Experienced candidates get something else. The interviewer describes a symptom, a bill that jumped or a leaked key, plus a teammate with a quick fix. Your job is to find the real cause and argue against the quick fix.

Below are six AWS scenarios that come up in DevOps and SRE loops, each with the prompt, the commands you would run, the pushback to expect, and a weak answer next to a strong one. For the overall shape of the interview, see how to pass a DevOps interview.

What these questions are really testing

Three things, in every scenario below:

  1. Do you diagnose before you spend or open up? Most quick fixes in AWS either cost money (bigger instance, more gateways) or widen access (public bucket, admin policy).
  2. Do you know which identity is making the call? aws sts get-caller-identity is often the first command, not the last.
  3. Do you weigh blast radius and cost together? A fix that saves money by exposing data is only half an answer.

A weak answer names a service. A strong one says what you will check, what the result will tell you, and what you will refuse to do while you check it.

Scenario 1: "An access key leaked. Just rotate it?"

The prompt: "Your app on EC2 talks to AWS using long-lived IAM user access keys stored in a config file on the instance, and one set just leaked. A teammate says generate new keys and paste them in. Do you agree, and what should you do instead?"

Rotating is part of the answer, but it only resets the timer on the same risk. Start by containing the leak and finding out what the key did:

aws iam update-access-key --user-name app-backend \
  --access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive

aws iam get-access-key-last-used --access-key-id AKIAIOSFODNN7EXAMPLE

aws cloudtrail lookup-events \
  --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIAIOSFODNN7EXAMPLE \
  --max-results 50

Deactivate before deleting so you can turn it back on if something critical breaks mid-migration. In CloudTrail, look for calls the app never makes: CreateUser, CreateAccessKey, RunInstances in an unused region. Disabling the first key does not stop a second IAM user the attacker created.

The real fix is to stop putting long-lived credentials on the instance at all. Attach a role through an instance profile so the SDK gets short-lived credentials from the instance metadata service, rotated automatically:

aws ec2 associate-iam-instance-profile --instance-id i-0abc123def4567890 \
  --iam-instance-profile Name=app-backend-profile

Then remove the keys from the config file and any AWS_ACCESS_KEY_ID environment variables. The SDK default credential chain checks those before instance metadata, so leftover keys silently win. Confirm what the app uses:

$ aws sts get-caller-identity
{
    "UserId": "AROAEXAMPLEID:i-0abc123def4567890",
    "Account": "123456789012",
    "Arn": "arn:aws:sts::123456789012:assumed-role/app-backend-role/i-0abc123def4567890"
}

An assumed-role ARN means the role is in use. A user/... ARN means a static key is still being picked up. Finally, require IMDSv2 so a server-side request forgery bug cannot read the role credentials with a single GET:

aws ec2 modify-instance-metadata-options --instance-id i-0abc123def4567890 \
  --http-tokens required --http-put-response-hop-limit 1

A hop limit of 1 keeps the token on the instance itself. Containers on a bridge network need 2; make that choice deliberately.

The pushback: "The app works with keys today. New keys get us running again in two minutes. Why re-architect auth during an incident?"

Weak answer Strong answer
"Fair, rotate now and fix it properly next quarter." "New keys are the same kind of credential that just leaked. An instance profile is also a few minutes of work, and it removes the thing that leaked instead of replacing it."
"We could encrypt the config file instead." "The app has to decrypt the key to use it, so it still exists in plaintext at runtime. Encryption adds key management without removing the long-lived secret."

The rest of the argument, how to scope the role, what to check in CloudTrail, and what to do about anything the attacker created, is what the challenge scores you on.

Practice this one: /challenges/aws-iam-keys-on-ec2

Scenario 2: "S3 returns 403. Make the bucket public?"

The prompt: "Your app gets 403 AccessDenied fetching objects from a private S3 bucket. A teammate says just turn off Block Public Access and make the bucket public so it works. Do you agree, and what do you do instead?"

A 403 is a permissions problem on one path. Going public changes the blast radius from one app to the internet, for every current and future object. The strong answer is an ordered checklist, starting with who is calling:

aws sts get-caller-identity
aws s3api head-object --bucket acme-app-assets --key reports/2026-11.pdf
An error occurred (403) when calling the HeadObject operation: Forbidden

Then the layers that can deny the request:

  1. Identity policy. Does the role allow s3:GetObject on arn:aws:s3:::acme-app-assets/reports/*? A missing /* is a classic cause: object actions need the object ARN.
  2. Bucket policy. aws s3api get-bucket-policy. Look for an explicit Deny, such as an aws:SourceVpce condition the caller does not meet. An explicit deny beats any allow.
  3. KMS. For SSE-KMS objects the caller also needs kms:Decrypt on the key, and the key policy must allow it. S3 permissions alone are not enough.
  4. Object ownership. aws s3api get-bucket-ownership-controls. If it is not BucketOwnerEnforced and another account uploaded the object, that account may still own it.
  5. Missing object. Without s3:ListBucket, S3 returns 403 instead of 404 for a key that does not exist. The "permission problem" can be a wrong key.

If the real requirement is a public website or public assets, the bucket still does not need to be public. Put CloudFront in front with Origin Access Control and allow only that distribution:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowCloudFrontOAC",
      "Effect": "Allow",
      "Principal": { "Service": "cloudfront.amazonaws.com" },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::acme-app-assets/*",
      "Condition": {
        "StringEquals": {
          "AWS:SourceArn": "arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE"
        }
      }
    }
  ]
}

This works with Block Public Access left on. For one user needing one file for a while, use a presigned URL.

The pushback: "The site is broken right now. Making it public makes the 403 go away immediately. Unblock first, tighten later."

Weak answer Strong answer
"OK, public for now, and we lock it down next sprint." "Public is instant for attackers too, and 'later' tends not to happen. The checklist takes minutes, and the fix is usually one missing line in a policy."
"Just make the individual objects public with ACLs." "ACLs are disabled under bucket-owner-enforced and they still expose the data. A scoped policy is easier to reason about and to audit."

Practice this one: /challenges/aws-s3-bucket-public

Scenario 3: "The NAT gateway bill exploded. Add another gateway?"

The prompt: "Cost Explorer shows NAT Gateway data processing charges have become your largest line item. Private-subnet instances pull large images and data from S3 and ECR. A teammate says it is just bandwidth, add another NAT gateway. What do you do?"

A classic AWS cost optimization interview question. A NAT gateway charges per hour and per gigabyte processed. Another gateway adds hourly cost and processes the same gigabytes at the same rate. The fix is to keep traffic off the NAT.

First confirm the growing usage type. NAT charges appear as NatGateway-Bytes and NatGateway-Hours, usually with a region prefix such as EUW1-:

aws ce get-cost-and-usage \
  --time-period Start=2026-10-01,End=2026-11-01 \
  --granularity MONTHLY --metrics UsageQuantity \
  --group-by Type=DIMENSION,Key=USAGE_TYPE \
  | jq -r '.ResultsByTime[].Groups[]
      | select(.Keys[0] | test("NatGateway"))
      | "\(.Keys[0])  \(.Metrics.UsageQuantity.Amount)"'

Then find the top talkers with VPC flow logs on the NAT gateway's network interface and a Logs Insights query:

filter interfaceId = "eni-0123456789abcdef0"
| stats sum(bytes) as bytesTransferred by srcAddr, dstAddr
| sort bytesTransferred desc
| limit 10

If the top destinations are S3 and ECR, the fix is endpoints:

  • S3 and DynamoDB: gateway endpoints. No hourly or data processing charge. Route table entries send that traffic around the NAT.
  • ECR: interface endpoints for ecr.api and ecr.dkr. These bill hourly per AZ and per gigabyte, so they are not free, but usually much cheaper per gigabyte than NAT. ECR layers live in S3, so pulls also need the S3 gateway endpoint.
aws ec2 create-vpc-endpoint --vpc-id vpc-0abc1234 \
  --service-name com.amazonaws.eu-west-1.s3 \
  --route-table-ids rtb-0private1a rtb-0private1b rtb-0private1c

Two caveats: a gateway endpoint only covers same-region buckets, and a too-narrow endpoint policy produces the 403s from Scenario 2. Then shrink what crosses the boundary: smaller images, ECR pull through cache, fewer redundant pulls.

The pushback: "Throughput is high, so we clearly need more NAT capacity. A second gateway is the obvious scaling move."

Weak answer Strong answer
"Yes, add one and split the subnets across them." "The bill is per gigabyte processed. Two gateways process the same gigabytes. One NAT per AZ is good for resilience and avoids cross-AZ charges, but it does not fix this line item."
"It is just bandwidth, every cloud charges for it." "This traffic is going to AWS services in the same region. Endpoints exist so it does not need to pay NAT processing."

The rest of the argument, how to prove which endpoints will pay for themselves and what to do about traffic that genuinely needs the internet, is what the challenge scores you on.

Practice this one: /challenges/aws-nat-gateway-cost

Scenario 4: "Lambda is exhausting RDS connections. Raise max_connections?"

The prompt: "During traffic spikes your Lambda functions start failing with too many connections errors against RDS. A teammate says just raise max_connections on the database. Do you agree, and what do you do instead?"

It is a connection storm, not a low limit: each concurrent Lambda execution environment holds its own connection, and code that connects inside the handler opens one per invocation. CloudWatch DatabaseConnections will track Lambda ConcurrentExecutions closely. On PostgreSQL:

SELECT state, count(*) FROM pg_stat_activity GROUP BY state;
        state        | count
---------------------+-------
 idle                |   412
 active              |    23
 idle in transaction |     4

Hundreds idle, a few dozen working: that is the signature. On RDS the default max_connections is derived from instance memory, because each connection costs memory. Raising it moves the failure from "connection refused" to "instance under memory pressure", which hurts every client.

The fix has three parts:

  1. Reuse the connection across invocations. Create it outside the handler so warm execution environments keep it:
import os
import psycopg2

conn = None

def handler(event, context):
    global conn
    if conn is None or conn.closed:
        conn = psycopg2.connect(os.environ["DB_DSN"], connect_timeout=5)
    with conn.cursor() as cur:
        cur.execute("SELECT 1")
  1. Put RDS Proxy in front. It multiplexes client connections onto a smaller database pool. It costs money, and session state such as SET commands can pin a client to one connection. Watch DatabaseConnectionsCurrentlySessionPinned.
  2. Cap concurrency. Reserved concurrency is a hard upper bound on connections:
aws lambda put-function-concurrency --function-name orders-api \
  --reserved-concurrent-executions 100

Alone, that turns database errors into throttles, so it complements the proxy.

The pushback: "It is one number in the parameter group. Why build a proxy when bumping max_connections is a one-line change?"

Weak answer Strong answer
"True, raise it and monitor memory." "The limit is tied to memory for a reason. The next bigger spike hits the new ceiling, and this time the instance itself is in trouble."
"Scale up to a bigger instance class." "That pays for more memory to hold idle connections. The per-invocation connection pattern is still broken."

Practice this one: /challenges/aws-rds-connection-storm

Scenario 5: "SQS delivers the same message twice. Switch to FIFO?"

The prompt: "Your workers sometimes process the same SQS message twice, leading to duplicate charges and emails. A teammate says standard SQS is broken and wants to move everything to FIFO. What is actually happening, and what do you do?"

Standard SQS is at-least-once by design, so consumers must tolerate duplicates. Frequent duplicates usually come from your own config. Compare the visibility timeout with job duration:

$ aws sqs get-queue-attributes --queue-url "$QUEUE_URL" \
    --attribute-names VisibilityTimeout RedrivePolicy
{
    "Attributes": {
        "VisibilityTimeout": "30"
    }
}

Thirty seconds is the default. A two-minute job reappears after 30 seconds and a second worker grabs it while the first is still charging the card. No RedrivePolicy also means no dead-letter queue. Fix it in layers:

  • Visibility timeout above worst-case processing time, or a ChangeMessageVisibility heartbeat. For a Lambda consumer, AWS recommends at least six times the function timeout.
  • Delete only after success, plus a dead-letter queue with a maxReceiveCount.
  • Make the side effect idempotent with a dedup key written conditionally:
aws dynamodb put-item --table-name processed-jobs \
  --item '{"jobId": {"S": "order-8812-charge"}}' \
  --condition-expression "attribute_not_exists(jobId)"

ConditionalCheckFailedException means the job already ran. Pass the same key to the payment provider as its idempotency key, if it supports one.

FIFO deduplicates sends within a five-minute window, but if a worker charges the card and crashes before deleting the message, it comes back and the charge runs again. FIFO also has lower throughput limits. It is for ordering, not a substitute for idempotency.

The pushback: "FIFO says exactly-once right in the docs. Flip every queue to FIFO and the duplicates vanish."

Weak answer Strong answer
"Yes, FIFO guarantees one delivery, let's migrate." "Exactly-once inside the queue does not cover the gap between the charge and the delete. The consumer still needs a dedup key, and our real bug is a 30-second timeout on a 2-minute job."
"Lower the visibility timeout so messages cycle faster." "That makes early redelivery more likely, which is the exact problem. The timeout has to be longer than the work."

Practice this one: /challenges/aws-sqs-duplicate-processing

Scenario 6: "The t3 instance got slow. Just size it up?"

The prompt: "Your service runs fine for a while, then gets slow under sustained traffic on a t3.medium. CPU looks pinned near a flat ceiling. A teammate says just upgrade to a bigger t3. What is really happening, and what do you do?"

A good AWS troubleshooting interview question, because the graph misleads if you do not know the family. T instances earn CPU credits below a baseline and spend them above it. A t3.medium's baseline is 20 percent per vCPU. In standard mode, at zero credits the instance is held at baseline: the flat ceiling. Check the balance and the mode:

aws cloudwatch get-metric-statistics --namespace AWS/EC2 \
  --metric-name CPUCreditBalance \
  --dimensions Name=InstanceId,Value=i-0abc123def4567890 \
  --start-time 2026-11-24T00:00:00Z --end-time 2026-11-25T00:00:00Z \
  --period 3600 --statistics Average

aws ec2 describe-instance-credit-specifications \
  --instance-ids i-0abc123def4567890
{
    "InstanceCreditSpecifications": [
        { "InstanceId": "i-0abc123def4567890", "CpuCredits": "standard" }
    ]
}

If CPUCreditBalance hits zero when latency climbs, that is the diagnosis. Mention the mode too: T3 launches in unlimited mode by default, so a throttled t3 usually means someone set standard on purpose. In unlimited mode you see CPUSurplusCreditsCharged and a bill line instead of a throttle.

Unlimited mode is a valid stopgap, but for load that is always above baseline it can cost more than a fixed-performance instance. The lasting fix is an M or C family instance sized from the metrics you just collected.

The pushback: "It is slow, so it needs more power. Bumping to the next t3 size is the normal fix."

Weak answer Strong answer
"Agreed, go to t3.large." "A bigger t3 has a higher baseline and more credits, but it is still burstable. Under sustained load it runs out later and throttles again, at a higher price."

Practice this one: /challenges/aws-ec2-burst-credits

More AWS scenarios to practice

Same pattern, each with its own challenge:

All of these, with the exact prompts, are collected on the AWS interview questions hub. If your loop also covers infrastructure as code, the same "read before you act" habit is tested in Terraform scenario based interview questions.

A pattern you can reuse in any AWS scenario

  1. Do not take the quick fix yet. Say what it would cost or expose.
  2. Find the identity with aws sts get-caller-identity.
  3. Read the metric that matches the mechanism: CPUCreditBalance, NatGateway-Bytes, DatabaseConnections.
  4. Find the top talker or the denying layer: flow logs, the policy chain, CloudTrail.
  5. Fix the mechanism: roles, endpoints, pooling, idempotency.
  6. Add a guard: IMDSv2, Block Public Access, a budget alert, a dead-letter queue.
  7. Name the trade-off. Interface endpoints, RDS Proxy and unlimited mode all cost money.

The free IAM guide, VPC networking guide and cost optimization guide cover the services used above in more depth.

Practicing under pushback

Knowing the answer is the easy part. In the interview, someone argues for the quick fix and watches whether you fold. A general chatbot makes up an answer on the spot. DevOps Ledger grades you against an answer key written before you started. Each scenario above has a challenge where you defend your call against that kind of pushback and see which arguments held up.

FAQ

What are AWS DevOps scenario based interview questions?

They describe an incident instead of asking for a definition: a leaked key, an S3 403, a NAT bill. You are scored on what you check first, which fix you choose, and how you defend it against a faster but riskier option.

What AWS questions are asked for experienced DevOps engineers?

Expect IAM and networking more than service trivia: instance roles and IMDSv2, why an S3 request is denied, VPC endpoints versus NAT, connection pooling for Lambda and RDS, SQS delivery semantics, and how to cut a cost line without opening access. Interviewers push back to see if you hold a correct position.

How do you answer an AWS cost optimization interview question?

Find the usage type that grew in Cost Explorer, then find what drives it, for example with VPC flow logs for NAT traffic. Fix the mechanism, such as gateway endpoints for S3, rather than adding capacity, and name what the fix itself costs.

Are S3 gateway endpoints free?

Yes. Gateway endpoints for S3 and DynamoDB have no hourly or data processing charge. They only cover the same region. Interface endpoints, used for services like ECR, do have hourly and per-gigabyte charges.

IMDSv2 requires a session token obtained with a PUT request before metadata can be read. That blocks the simple server-side request forgery attack where a vulnerable app is tricked into fetching role credentials from the metadata endpoint with a GET.

Practice these scenarios

Free guides to read next

Practice defending your decisions

DevOps Ledger is a scenario-based DevOps and SRE interview practice platform: you pick a real production incident, defend your decision in a chat against a senior-engineer AI that pushes back, and get scored against an answer key written before you started.

One payment. 12 months of access. No subscription, nothing renews.

Get full access - $19