Skip to content
RED SAGSkills

AWS interview questions and answers

AWS interview questions test the core services teams build on and how to use them securely and cheaply.

Below are 60 AWS questions with the correct answer and a short explanation, grouped from fresher to experienced level. Try each one before you open the answer.

What AWS interviews usually check

  • ✓EC2, Lambda and containers
  • ✓S3 and storage classes
  • ✓VPC, security groups and networking
  • ✓IAM roles and policies
  • ✓CloudWatch, scaling and cost control

AWS interview questions for freshers easy

1. SNS to SQS fan-out

On AWS, one event must reach three services, and each service must be able to fall behind without losing messages. What is the common setup?

  1. A.One SQS queue read by all three services
  2. B.Three Lambda functions calling each other in a chain
  3. C.One SNS topic with each service subscribed over HTTP only
  4. D.One SNS topic with an SQS queue subscribed per service
Show answer

Answer: D. One SNS topic with an SQS queue subscribed per service

SNS fans the event out and each service gets its own SQS queue, which buffers messages while that service is slow or down. A single shared queue would give each message to only one service. Plain HTTP subscriptions have limited retries and no buffer if the service is down for long.

2. What cdk synth produces

With the AWS CDK you write TypeScript classes. What does cdk synth produce from them?

  1. A.A Terraform state file
  2. B.An Ansible playbook
  3. C.A CloudFormation template
  4. D.A Docker image
Show answer

Answer: C. A CloudFormation template

The CDK is a code layer on top of CloudFormation: synth turns your constructs into CloudFormation templates, and cdk deploy hands them to CloudFormation. So CloudFormation limits and rollback behaviour still apply. cdk diff shows the change before deploy.

3. Who patches the VM operating system?

Your team runs an application on an Amazon EC2 virtual machine. Under the shared responsibility model, who is responsible for patching the guest operating system on that VM?

  1. A.AWS, because it owns the hardware
  2. B.The customer, because the guest OS is part of what the customer manages
  3. C.Nobody, because EC2 patches itself automatically
  4. D.The operating system vendor, such as Canonical or Microsoft
Show answer

Answer: B. The customer, because the guest OS is part of what the customer manages

With IaaS services like EC2, the cloud provider secures the physical hosts, network and hypervisor, while the customer manages the guest OS, applications and data. You can automate patching with tools like AWS Systems Manager Patch Manager, but the responsibility is still yours. With managed services such as RDS or Lambda, the provider takes over OS patching.

4. How serverless functions are billed

How is a typical serverless function service like AWS Lambda billed?

  1. A.A fixed monthly fee per function
  2. B.Per hour the function is deployed, whether or not it runs
  3. C.Only by the size of the deployment package
  4. D.By the number of requests and the compute time used, based on memory size and duration
Show answer

Answer: D. By the number of requests and the compute time used, based on memory size and duration

Lambda charges per request plus compute duration measured in GB-seconds (memory allocated multiplied by run time). When the function is idle you pay nothing for compute. This makes serverless very cheap for spiky or low-traffic workloads, but it can cost more than containers for constant heavy load.

5. Usable IPs in a /24 subnet

You create a subnet with CIDR 10.0.1.0/24 in an AWS VPC. How many IP addresses can you actually assign to resources in it?

  1. A.251
  2. B.256
  3. C.254
  4. D.128
Show answer

Answer: A. 251

A /24 has 2^8 = 256 addresses. AWS reserves 5 in every subnet: the network address, the VPC router, the DNS server, one reserved for future use, and the broadcast address. That leaves 251 assignable addresses, which matters when you size subnets for many pods or instances.

6. Alerting on high CPU

You want a notification when average CPU on an EC2 instance stays above 80 percent for 10 minutes. What do you create?

  1. A.A CloudWatch Logs subscription filter
  2. B.An AWS CloudTrail trail
  3. C.An S3 event notification
  4. D.A CloudWatch metric alarm on CPUUtilization
Show answer

Answer: D. A CloudWatch metric alarm on CPUUtilization

CloudWatch metric alarms watch a metric over a period and number of datapoints, then notify an SNS topic or take an action. CPUUtilization is a built-in EC2 metric. CloudTrail records API calls, and log subscription filters stream logs; neither is the simple tool for a CPU threshold.

7. Shell access without opening port 22

Admins need a shell on instances in private subnets, but security forbids inbound SSH. What should you use?

  1. A.Attach a public IP address to each instance
  2. B.Allow port 22 from 0.0.0.0/0 for a few hours
  3. C.Share one SSH key through an S3 bucket
  4. D.AWS Systems Manager Session Manager
Show answer

Answer: D. AWS Systems Manager Session Manager

Session Manager opens shells through the SSM agent, which makes outbound connections, so no inbound port or bastion is needed. Access is controlled with IAM and sessions can be logged to CloudWatch or S3. Azure Bastion and GCP IAP TCP forwarding solve the same problem on other clouds.

8. Picking an instance family

You need a VM for a large in-memory cache that needs lots of RAM but modest CPU. Which EC2 family fits best?

  1. A.Compute optimised, such as C family
  2. B.Burstable general purpose, such as T family
  3. C.Accelerated computing, such as P family
  4. D.Memory optimised, such as R family
Show answer

Answer: D. Memory optimised, such as R family

Memory-optimised instances (R and X families on AWS; E and M series on Azure; M and highmem types on Google Cloud) give a high RAM-to-CPU ratio. C types are for CPU-heavy work, T for low steady usage, and P for GPU workloads.

9. Data on an instance store

An app writes files to an EC2 instance store volume. What happens to the files if the instance is stopped?

  1. A.They are kept, like on an EBS volume
  2. B.They are moved to S3 automatically
  3. C.They are copied to a snapshot first
  4. D.They are lost; instance store is temporary
Show answer

Answer: D. They are lost; instance store is temporary

Instance store is physically attached to the host and is very fast, but its data is lost when the instance stops, terminates or the hardware fails. Use EBS or S3 for anything you need to keep.

10. Who deleted the bucket?

Someone deleted an S3 bucket last night. Which AWS service records who made that API call?

  1. A.CloudWatch metrics
  2. B.CloudTrail
  3. C.AWS Config rules only
  4. D.Trusted Advisor
Show answer

Answer: B. CloudTrail

CloudTrail logs API calls: who, what, when and from where. CloudWatch collects metrics, logs and alarms about performance. Azure's equivalent of CloudTrail is the Activity Log; Google Cloud has Cloud Audit Logs.

11. Durability vs availability

S3 Standard is designed for 99.999999999% durability and 99.99% availability. What does the durability figure describe?

  1. A.How often the service answers requests
  2. B.How unlikely it is that stored data is lost
  3. C.How fast objects can be downloaded
  4. D.How long objects stay in the cache
Show answer

Answer: B. How unlikely it is that stored data is lost

Durability is the chance your data survives over time; eleven nines means loss is extremely unlikely. Availability is the share of time you can access it. Data can be durable but briefly unavailable.

12. Longest a Lambda can run

What is the maximum time a single AWS Lambda invocation can run?

  1. A.5 minutes
  2. B.1 hour
  3. C.15 minutes
  4. D.24 hours
Show answer

Answer: C. 15 minutes

Lambda functions can be configured to run up to 15 minutes per invocation. Longer jobs should be split into steps (for example with Step Functions) or run on containers or batch services.

13. What Fargate removes

When you run ECS or EKS tasks on AWS Fargate, what do you no longer manage?

  1. A.The container images for your app
  2. B.The CPU and memory each task needs
  3. C.Your application's code and config
  4. D.The servers or nodes that run the containers
Show answer

Answer: D. The servers or nodes that run the containers

Fargate runs containers without you provisioning or patching EC2 nodes; you define CPU and memory per task. You still build images and manage your app. Azure Container Apps and Cloud Run are similar serverless container platforms.

14. What a key management service does

What is the main job of AWS KMS, Azure Key Vault keys or Google Cloud KMS?

  1. A.Creating and controlling encryption keys
  2. B.Storing large files cheaply
  3. C.Load balancing HTTPS traffic
  4. D.Sending email notifications
Show answer

Answer: A. Creating and controlling encryption keys

Key management services create, store and control use of encryption keys, with IAM policies and audit logs. Storage and database services call them to encrypt data, so you control who can decrypt.

15. Storage class for unpredictable access

A data lake has objects whose access patterns you cannot predict. Which S3 storage class automatically moves objects between tiers based on use?

  1. A.S3 Standard
  2. B.S3 Intelligent-Tiering
  3. C.S3 One Zone-IA
  4. D.S3 Glacier Deep Archive
Show answer

Answer: B. S3 Intelligent-Tiering

Intelligent-Tiering monitors access and moves objects to cheaper tiers when they are not used, and back when they are, for a small monitoring fee per object. It suits unknown or changing patterns; very small objects are not moved.

16. S3 Block Public Access

What does turning on S3 Block Public Access at the account level do?

  1. A.Encrypts every object in every bucket with a new key
  2. B.Overrides policies and ACLs that would make buckets or objects public
  3. C.Blocks all access to S3 from outside the company VPN
  4. D.Deletes any object that was uploaded with a public ACL
Show answer

Answer: B. Overrides policies and ACLs that would make buckets or objects public

Block Public Access is a set of guardrails that ignore or reject public ACLs and public bucket policies, even if someone adds them later. Applied at account level, it protects every bucket in that account. It does not encrypt data or block normal authenticated access from your own principals.

17. Protecting backups from deletion

Your backups in S3 must not be deletable, even by an admin whose credentials are stolen, for 30 days. Which feature fits?

  1. A.S3 Object Lock in compliance mode with a 30-day retention
  2. B.S3 Transfer Acceleration on the backup bucket
  3. C.S3 Intelligent-Tiering for every backup object
  4. D.An S3 lifecycle rule that moves backups to Glacier
Show answer

Answer: A. S3 Object Lock in compliance mode with a 30-day retention

Object Lock stores objects in WORM (write once, read many) form. In compliance mode, no one, including the root user, can delete or shorten the retention until it ends. This is a strong defence against ransomware and insider deletion; AWS Backup Vault Lock offers the same for backup vaults.

18. Continuous configuration checks

You want an alert whenever someone creates an unencrypted EBS volume or an S3 bucket without Block Public Access. Which AWS service is built for this?

  1. A.AWS Cost Explorer
  2. B.Amazon Route 53
  3. C.AWS Step Functions
  4. D.AWS Config rules
Show answer

Answer: D. AWS Config rules

AWS Config records resource configurations over time and evaluates them against rules, managed or custom. Non-compliant resources are flagged and can trigger automatic remediation. Azure Policy and GCP organization policies with Security Command Center play similar roles.

19. One view of security findings

Your team has findings spread across GuardDuty, Inspector, Macie and Config in 30 accounts. Which AWS service brings them into one place with security scores?

  1. A.AWS Organizations
  2. B.AWS Security Hub
  3. C.AWS Systems Manager
  4. D.Amazon EventBridge
Show answer

Answer: B. AWS Security Hub

Security Hub collects and normalises findings from AWS services and partners across accounts and regions, and runs standards checks such as the AWS Foundational Security Best Practices and CIS benchmarks. Organizations manages accounts, and EventBridge can route findings, but neither aggregates and scores them.

20. VPN or a dedicated link

A Dubai bank needs a private, consistent-latency link from its data centre to AWS for heavy daily data transfer. Which option fits best?

  1. A.A site-to-site VPN over the public internet
  2. B.A dedicated link such as AWS Direct Connect
  3. C.Public endpoints protected only by TLS
  4. D.A VPC peering connection to the data centre
Show answer

Answer: B. A dedicated link such as AWS Direct Connect

Direct Connect (Azure ExpressRoute, Google Cloud Interconnect) is a private circuit with predictable latency and bandwidth. A VPN over the internet is quick and cheap to set up but its performance varies. Peering only connects VPCs.

AWS intermediate interview questions medium

21. Checking an interleaving of two strings

You check whether s3 is formed by interleaving s1 and s2 while keeping each one’s order. What does dp[i][j] mean?

  1. A.Whether s1[i] is equal to s2[j]
  2. B.If s1[0..i) and s2[0..j) can form s3[0..i+j)
  3. C.How many times s1 appears inside s3
  4. D.The length of the LCS of s1[0..i) and s2[0..j)
Show answer

Answer: B. If s1[0..i) and s2[0..j) can form s3[0..i+j)

dp[i][j] is true if the last character of s3’s prefix came from s1 (dp[i - 1][j] and s1[i - 1] matches) or from s2 (dp[i][j - 1] and s2[j - 1] matches). If the lengths do not add up, return false at once. Greedy matching fails when both strings offer the same next character.

22. Visibility timeout for a Lambda trigger

An SQS queue triggers a Lambda function whose timeout is 60 seconds. What visibility timeout does AWS recommend for the queue?

  1. A.At least 360 seconds, six times the function timeout
  2. B.Exactly 60 seconds, the same as the function
  3. C.30 seconds, so failures retry quickly
  4. D.0 seconds, Lambda manages visibility itself
Show answer

Answer: A. At least 360 seconds, six times the function timeout

AWS recommends a queue visibility timeout of at least six times the function timeout. This leaves room for retries when Lambda is throttled while processing a batch. If the visibility timeout is shorter than processing time, the message reappears and another invocation processes it again.

23. Private invoice downloads from S3

Invoices live in a private S3 bucket. How should the app let a logged-in user download their own invoice?

  1. A.Make the bucket public and use random file names
  2. B.Email the S3 access keys to the user securely
  3. C.Store the invoice PDF in the browser localStorage
  4. D.Check ownership, then return a short-lived signed URL
Show answer

Answer: D. Check ownership, then return a short-lived signed URL

A pre-signed URL grants time-limited access to one object without exposing keys. The server must first check the user owns that invoice. Keep expiry short, such as a few minutes.

24. Locking with the S3 backend today

You are setting up a new S3 backend with Terraform 1.11 or later. What is the recommended way to get state locking?

  1. A.Locking is not possible with the S3 backend
  2. B.Set encrypt = true, which also locks the state
  3. C.Create a DynamoDB table, as it is the only option
  4. D.Set use_lockfile = true so S3 itself holds the lock
Show answer

Answer: D. Set use_lockfile = true so S3 itself holds the lock

Since Terraform 1.10, the S3 backend can lock using a lock file in the bucket with conditional writes (use_lockfile = true), and the DynamoDB option is deprecated. Existing DynamoDB setups still work and can run both during migration. encrypt only controls server-side encryption.

25. Hardening the state bucket

Your Terraform state lives in an S3 bucket. Which set of settings matters most?

  1. A.Versioning, encryption, blocked public access, tight IAM
  2. B.Static website hosting and a CDN in front
  3. C.Lifecycle rules that delete old objects after a day
  4. D.Public read so CI runners can fetch it fast
Show answer

Answer: A. Versioning, encryption, blocked public access, tight IAM

State can hold secrets and is the source of truth, so it needs encryption, no public access and least-privilege IAM. Versioning lets you restore an earlier state if one is corrupted or wrongly overwritten. Deleting old versions quickly removes that safety net.

26. Moving to a newer provider

You raise the AWS provider constraint from ~> 5.60 to ~> 6.0. init fails saying the locked version does not match. What do you run?

  1. A.Delete the state file and run init again
  2. B.terraform validate -lock=false
  3. C.terraform init -upgrade, then commit the lock file
  4. D.terraform apply -upgrade
Show answer

Answer: C. terraform init -upgrade, then commit the lock file

The lock file pins the exact provider version. init -upgrade picks the newest version allowed by the constraints and rewrites .terraform.lock.hcl, which you commit. Read the major version upgrade guide and check the plan for unexpected replacements.

27. One provider per region in a loop

You need the same resources in 6 AWS regions. Which feature, added in OpenTofu 1.9, removes the need for 6 hand-written provider blocks?

  1. A.count on module blocks
  2. B.for_each on provider blocks
  3. C.dynamic provider blocks
  4. D.provider_meta with a region list
Show answer

Answer: B. for_each on provider blocks

OpenTofu 1.9 allows for_each on provider configurations, so one block can create an aliased instance per region, and modules or resources pick one with a key like aws.by_region["ap-south-1"]. In Terraform you still write one provider block per alias. count and for_each on modules existed long before.

28. Reducing serverless cold starts

A latency-sensitive API on AWS Lambda shows slow first responses after idle periods. Which option most directly removes cold starts for a predictable number of requests?

  1. A.Configure provisioned concurrency for the function
  2. B.Increase the function timeout to 15 minutes
  3. C.Move the function into a VPC
  4. D.Reduce the reserved concurrency to 1
Show answer

Answer: A. Configure provisioned concurrency for the function

Provisioned concurrency keeps a set number of execution environments initialized and ready, so those requests skip the cold start. Smaller packages, faster runtimes and SnapStart (for supported runtimes) also help. A longer timeout does nothing for startup, and limiting concurrency can cause throttling.

29. Failed async Lambda events

S3 invokes a Lambda function asynchronously. Some events fail every time. What happens by default, and how do you keep them?

  1. A.Lambda keeps retrying forever until it succeeds
  2. B.Failed events are put back into S3 automatically
  3. C.Lambda retries twice; add an on-failure destination
  4. D.Async events cannot fail once Lambda accepts them
Show answer

Answer: C. Lambda retries twice; add an on-failure destination

For asynchronous invocations, Lambda retries failed events twice by default and then drops them. Configure an on-failure destination (SQS, SNS, EventBridge, Lambda) or a dead-letter queue to capture them for inspection.

30. Capacity mode for unpredictable traffic

A new app has unknown, spiky traffic and low average use. Which DynamoDB capacity mode is usually the best start?

  1. A.On-demand, paying per request
  2. B.Provisioned at the expected peak
  3. C.Provisioned at the expected average
  4. D.Reserved capacity for three years
Show answer

Answer: A. On-demand, paying per request

On-demand capacity scales automatically and bills per read and write, so you do not pay for idle provisioned throughput. For steady, predictable load, provisioned capacity with auto scaling (and reservations) can be cheaper.

31. Log storage growing forever

CloudWatch Logs storage cost rises every month. The log groups were created by default by many Lambda functions. What is the likely cause?

  1. A.CloudWatch raises its per-GB storage price every month
  2. B.Retention defaults to "never expire", so logs pile up
  3. C.Lambda writes every log line twice by default
  4. D.Log groups can only be deleted by AWS support
Show answer

Answer: B. Retention defaults to "never expire", so logs pile up

New CloudWatch log groups keep data forever unless you set a retention period. Set retention (for example 30 days) in your IaC, export long-term logs to cheaper S3 storage if needed, and reduce noisy debug logging.

32. Effect of a permissions boundary

A role has an identity policy allowing s3:* and ec2:*, and a permissions boundary that allows s3:* and dynamodb:*. What can the role do?

  1. A.Only S3 actions
  2. B.S3, EC2 and DynamoDB actions
  3. C.Only EC2 and DynamoDB actions
  4. D.Nothing, because the policies conflict
Show answer

Answer: A. Only S3 actions

A permissions boundary sets the maximum permissions; the effective permissions are the intersection of the identity policy and the boundary. S3 is in both, so it works. EC2 is not in the boundary and DynamoDB is not in the identity policy, so neither is allowed.

33. Sharing an encrypted snapshot

You try to share an EBS snapshot encrypted with the aws/ebs managed key with a partner account, and it fails. Why?

  1. A.AWS managed keys cannot be shared with other accounts
  2. B.Encrypted snapshots can never be shared across accounts
  3. C.The partner account must be in a different region
  4. D.Snapshots can only be shared if they are public
Show answer

Answer: A. AWS managed keys cannot be shared with other accounts

To share an encrypted snapshot or AMI, it must use a customer managed key whose key policy allows the other account to use it. Copy the snapshot re-encrypted with such a key, update the key policy, then share. AWS managed keys have fixed policies you cannot change.

34. Sharing a private S3 file briefly

Customers must download their own invoice PDF from a private bucket without having AWS accounts. What is a safe way?

  1. A.Make the invoice folder public and use long random file names
  2. B.Generate a pre-signed URL that expires after a few minutes
  3. C.Email the customer the access key of a read-only IAM user
  4. D.Copy each invoice to a public bucket and delete it next week
Show answer

Answer: B. Generate a pre-signed URL that expires after a few minutes

A pre-signed URL carries a signature from your app's credentials and works only for that object and only until it expires. The bucket stays private. Keep expiry short, and remember the URL works for whoever has it until then.

35. Private S3 origin behind CloudFront

A static site is served through CloudFront from an S3 bucket. You want the bucket private so users cannot bypass CloudFront. What should you use?

  1. A.S3 static website hosting with the bucket set to public read
  2. B.A security group on the S3 bucket that allows CloudFront IPs
  3. C.Origin Access Control plus a bucket policy allowing only that distribution
  4. D.Signed cookies on the bucket and public ACLs on each object
Show answer

Answer: C. Origin Access Control plus a bucket policy allowing only that distribution

Origin Access Control lets CloudFront sign requests to S3, and the bucket policy allows the cloudfront.amazonaws.com principal only when aws:SourceArn is your distribution. The bucket stays private with Block Public Access on. S3 buckets do not have security groups.

36. IMDSv2 and containers

You enforce IMDSv2 on EC2 nodes running containers. You want pods to be unable to reach the node's instance metadata credentials. What helps?

  1. A.Set the metadata response hop limit to 1
  2. B.Set the metadata response hop limit to 64
  3. C.Turn IMDSv1 back on for the containers
  4. D.Open port 80 on the node's security group
Show answer

Answer: A. Set the metadata response hop limit to 1

IMDSv2 tokens are returned with an IP TTL equal to the hop limit. With a limit of 1 the response cannot cross the extra network hop into a bridged container network, so pods cannot get the node role's credentials. Pods should get their own credentials through EKS Pod Identity or IRSA instead.

37. Speeding up a global UDP service

A multiplayer game backend uses UDP and runs in Bahrain and Mumbai. You want static anycast IPs and traffic carried over the AWS backbone. Which service fits?

  1. A.Amazon CloudFront
  2. B.Route 53 weighted records only
  3. C.AWS Global Accelerator
  4. D.An Application Load Balancer
Show answer

Answer: C. AWS Global Accelerator

Global Accelerator gives two static anycast IPs, takes users onto the AWS network at the nearest edge and routes TCP or UDP to healthy regional endpoints. CloudFront is an HTTP cache and ALB is HTTP-only and regional.

38. SageMaker Pipelines step cache

With step caching on in SageMaker Pipelines, when is a previous step result reused?

  1. A.Whenever the step name is the same as in yesterday’s run
  2. B.Only when the pipeline runs again within the same hour
  3. C.When its arguments and inputs match a prior successful run
  4. D.Never, because caching only applies to training job steps
Show answer

Answer: C. When its arguments and inputs match a prior successful run

SageMaker compares a step’s configuration and inputs with earlier successful executions within the expiry window. If they match, it reuses the output. Inputs that change silently, like "latest" paths, can make cache hits stale.

39. Mapping over files found at run time

list_files() returns a different number of S3 keys each day, and process.expand(key=list_files()) follows. When is the number of process instances decided?

  1. A.When the DAG file is parsed by the processor
  2. B.After list_files finishes and returns its list
  3. C.When the DAG is unpaused for the first time
  4. D.Once, on the first run, then reused
Show answer

Answer: B. After list_files finishes and returns its list

Dynamic task mapping expands at run time: after the upstream task finishes, the scheduler reads its XCom and creates one mapped instance per item. So each day gets as many instances as there are files, with no change to the DAG file.

40. A partner sells through the marketplace

A customer wants to buy your SaaS through AWS Marketplace but also wants its usual local reseller involved. Which option fits?

  1. A.A channel partner private offer via the reseller
  2. B.The customer must choose either AWS or the reseller
  3. C.The reseller lists your product as its own
  4. D.The deal cannot use the marketplace
Show answer

Answer: A. A channel partner private offer via the reseller

Channel partner private offers let a reseller or consulting partner create the marketplace offer with its own margin, while the customer still buys through AWS and can use committed spend. It keeps the partner in the deal instead of cutting it out.

AWS interview questions for experienced candidates hard

41. Stale callback in a long effect

One second after Splash appears, the parent passes a new onTimeout lambda. Which lambda is called after 3 seconds?

@Composable
fun Splash(onTimeout: () -> Unit) {
  LaunchedEffect(Unit) {
    delay(3000)
    onTimeout()
  }
}
  1. A.The newest lambda, because composables always read the latest parameters
  2. B.The original lambda captured when the effect started; use val currentOnTimeout by rememberUpdatedState(onTimeout) and call that instead
  3. C.Both lambdas, one after the other
  4. D.Neither; a new lambda parameter restarts every LaunchedEffect in the composable, so the 3 second timer resets each time the parent passes one
Show answer

Answer: B. The original lambda captured when the effect started; use val currentOnTimeout by rememberUpdatedState(onTimeout) and call that instead

The effect coroutine was started once with the onTimeout value from the first composition, and its key Unit never changes, so it keeps calling that old lambda. Keying the effect on onTimeout would restart the timer, which is not wanted. rememberUpdatedState keeps a reference that always points to the latest lambda without restarting the effect.

42. Removing a module that has its own provider

An old child module contains its own provider "aws" block. You delete the module call to destroy its resources, and plan fails with "Provider configuration not present". Why?

  1. A.The provider binary was deleted from the .terraform folder
  2. B.The provider config needed to destroy them left with the module
  3. C.The state lock is still held by the old module
  4. D.Child modules cannot hold resources that need destroying
Show answer

Answer: B. The provider config needed to destroy them left with the module

To destroy resources Terraform needs the provider configuration that manages them, and it disappeared with the module. Fix it by first destroying with the module still present, or move the provider to the root and pass it in. This is why child modules should not declare their own provider blocks.

43. S3 consistency model

An application overwrites an existing S3 object with a new version (a successful PUT), then immediately sends a GET for the same key from another service. What does the GET return today?

  1. A.The new version, because S3 provides strong read-after-write consistency
  2. B.Either the old or new version, because S3 overwrites are eventually consistent
  3. C.A 404 error until replication finishes
  4. D.The old version for up to 15 minutes
Show answer

Answer: A. The new version, because S3 provides strong read-after-write consistency

Since December 2020, Amazon S3 provides strong read-after-write consistency for PUTs and DELETEs of objects, including overwrites and LIST operations, in all regions at no extra cost. Older material describing eventual consistency for overwrites is outdated. Cross-region replication, however, is still asynchronous.

44. Active-active writes across regions

You run an active-active app in two regions using DynamoDB global tables (default multi-region eventual consistency mode). Users in both regions update the same item at nearly the same time. What happens?

  1. A.Both writes are merged field by field automatically
  2. B.Replication resolves the conflict with last writer wins, so one update is silently lost
  3. C.The second write fails with a conflict error that the client must retry
  4. D.The table goes read-only until an operator resolves the conflict
Show answer

Answer: B. Replication resolves the conflict with last writer wins, so one update is silently lost

In the default eventually consistent mode, DynamoDB global tables replicate asynchronously and resolve concurrent writes to the same item with last writer wins based on timestamps. One update can be lost without an error. Designs handle this by routing a given user or record to a single home region, using conditional writes or version counters, or choosing the strongly consistent multi-region mode where it fits.

45. Lambda spike breaks the database

During a traffic spike, a Lambda function scales to 800 concurrent executions and RDS PostgreSQL starts returning "too many connections". What is the best fix?

  1. A.Increase the Lambda timeout so connections can wait longer
  2. B.Move the Lambda out of the VPC to use public endpoints
  3. C.Give the function more memory to reuse connections
  4. D.Add RDS Proxy and cap the function with reserved concurrency
Show answer

Answer: D. Add RDS Proxy and cap the function with reserved concurrency

Each concurrent Lambda environment opens its own connections, so fast scaling overwhelms the database connection limit. RDS Proxy pools and reuses connections, and reserved concurrency caps how far the function can scale. Memory and timeout changes do not reduce connection count.

46. A function that triggers itself

A Lambda function is triggered by uploads to a bucket, resizes the image and writes the result back to the same bucket. The bill explodes overnight. Why?

  1. A.Image resizing is billed per pixel processed
  2. B.Each output upload re-triggers the function in a loop
  3. C.S3 charges more for objects written by Lambda
  4. D.Lambda retries every invocation 100 times by default
Show answer

Answer: B. Each output upload re-triggers the function in a loop

Writing outputs into the bucket that triggers the function creates a recursive loop. Write results to a different bucket, or filter the trigger by prefix or suffix so outputs do not match. Set alarms on invocation counts.

47. A new item missing from the index

Right after writing an order, a query on a DynamoDB global secondary index sometimes does not return it. Strongly consistent reads give an error on the GSI. Why?

  1. A.GSIs update asynchronously and allow only eventual reads
  2. B.The write must have failed silently in the table
  3. C.GSIs only show new items after a full hour
  4. D.The partition key value was too long to index
Show answer

Answer: A. GSIs update asynchronously and allow only eventual reads

Global secondary indexes are updated asynchronously from the base table and do not support strongly consistent reads. Usually the lag is short. If you need read-after-write, read the base table by its key.

48. An ML library too big for a zip

Your Lambda function needs ML libraries totalling 1.5 GB unzipped. The zip deployment fails. What is the supported option?

  1. A.Split the code across 10 Lambda layers
  2. B.Package it as a container image, which allows up to 10 GB
  3. C.Upload the zip to S3 first; it removes the limit
  4. D.Compress the libraries twice
Show answer

Answer: B. Package it as a container image, which allows up to 10 GB

Zip packages including layers are limited to 250 MB unzipped. Lambda container images can be up to 10 GB. Large images can slow cold starts, so trim dependencies and consider whether a container service fits better.

49. Protecting tags used for ABAC

Your ABAC policies grant access when aws:ResourceTag/team matches aws:PrincipalTag/team. What extra control is essential?

  1. A.Make all tag keys and values lowercase everywhere
  2. B.Turn on S3 versioning for every bucket in scope
  3. C.Use only AWS managed policies for the roles
  4. D.Stop principals from changing their own or resources' tags
Show answer

Answer: D. Stop principals from changing their own or resources' tags

If a user can run iam:TagRole on their own role or ec2:CreateTags to change a resource's team tag, they can grant themselves access to any team's resources. Restrict tag-changing actions with conditions on aws:TagKeys and aws:RequestTag, or set principal tags only from the identity provider as session tags.

50. KMS grants

An application needs to give an AWS service temporary permission to use a key for one job, then remove it, without editing the key policy each time. What KMS feature is designed for this?

  1. A.Grants, which delegate key use and can be retired or revoked
  2. B.Aliases, which point a friendly name at the key
  3. C.Multi-Region keys, which copy the key to other regions
  4. D.Key rotation, which creates a new key for each job
Show answer

Answer: A. Grants, which delegate key use and can be retired or revoked

Grants give a principal specific operations on a key and are created and retired programmatically, which is how services like EBS and RDS get key access. Key policies are for durable access rules. Use grant constraints, such as encryption context, to narrow what a grant allows.

51. Changing a bucket's default key

You change an S3 bucket's default encryption from key A to key B, then disable key A a week later. Users report old files fail to download. Why?

  1. A.Existing objects stay encrypted under key A until rewritten
  2. B.S3 re-encrypts old objects slowly and had not finished yet
  3. C.Key B cannot decrypt objects older than its own creation date
  4. D.Disabling a key deletes every object encrypted under it
Show answer

Answer: A. Existing objects stay encrypted under key A until rewritten

Default encryption applies only to new writes; existing objects keep the key they were written with. With key A disabled, S3 cannot decrypt them. Re-encrypt old objects first, for example with S3 Batch Operations copying them in place with key B, and only then disable the old key.

52. Preventive vs detective controls

Your organization blocks public S3 buckets with an SCP and Block Public Access, and also runs a Config rule that flags public buckets. Why keep both?

  1. A.Config rules are required before SCPs can be attached
  2. B.SCPs only work if a Config rule is also deployed
  3. C.There is no reason; the Config rule is fully redundant
  4. D.Detective controls catch gaps and exceptions the preventive ones miss
Show answer

Answer: D. Detective controls catch gaps and exceptions the preventive ones miss

Defence in depth assumes any single control can fail or be exempted, for example in an account outside the OU, an approved exception, or a new access path. Detective controls show you when reality drifts from intent. Preventive and detective controls work best together, with automated remediation where safe.

53. Building an S3 data perimeter

You want company buckets usable only by your own identities and only from your networks. Which combination expresses this data perimeter?

  1. A.Security groups on each bucket that allow only office IP ranges
  2. B.A NAT gateway in every VPC and a public bucket policy
  3. C.Bucket policies that deny unless PrincipalOrgID and SourceVpce match
  4. D.Encrypting every bucket with SSE-S3 and enabling versioning
Show answer

Answer: C. Bucket policies that deny unless PrincipalOrgID and SourceVpce match

A data perimeter uses deny statements with conditions such as aws:PrincipalOrgID (trusted identities) and aws:SourceVpce or aws:SourceIp (expected networks), with exceptions for AWS services acting for you. VPC endpoint policies add the mirror check that your networks reach only your resources. Buckets have no security groups, and SSE-S3 does not limit who can read.

54. Low traffic makes WAL archiving lag

DR relies only on WAL archiving to S3, with no streaming replica. At night traffic is low and a 16 MB WAL segment can take 3 hours to fill. What limits data loss to about one minute?

  1. A.Raise max_wal_size to 64 GB
  2. B.Set archive_timeout = 60s
  3. C.Set wal_level = minimal
  4. D.Lower checkpoint_timeout to 30s
Show answer

Answer: B. Set archive_timeout = 60s

A segment is archived only when it is full or a switch is forced. archive_timeout forces a switch after the given time, so at most about a minute of changes sit unarchived. Each forced switch still archives a 16 MB file, so very low values waste storage; streaming gives an even lower RPO.

55. A role trust policy that adds a stranger

CloudTrail shows UpdateAssumeRolePolicy on an admin role, adding an AWS account ID nobody recognises to the trust policy. What is the risk?

  1. A.The role is deleted after 24 hours
  2. B.The role loses all its permissions
  3. C.Only billing data is shared with that account
  4. D.That external account can now assume the admin role
Show answer

Answer: D. That external account can now assume the admin role

The trust policy says who may assume a role. Adding an outside account gives a persistent backdoor that survives password and key resets inside your account. Alert on trust policy changes and use IAM Access Analyzer to flag external access.

56. GitHub OIDC role without a sub check

An AWS role trusts GitHub's OIDC provider and its trust policy checks only that the token's aud is sts.amazonaws.com. What is the risk, and the fix?

  1. A.Tokens expire too fast; raise the session duration to 12 hours
  2. B.Workflows in other repos could assume it; restrict the sub claim
  3. C.GitHub will reject the role; add an access key as fallback
  4. D.Only public repos can use it; switch to a client secret
Show answer

Answer: B. Workflows in other repos could assume it; restrict the sub claim

Every GitHub Actions token has the same issuer and can carry that audience, so without a sub condition the role trusts workflows from repositories you do not own. Add a condition on token.actions.githubusercontent.com:sub such as repo:your-org/your-repo:ref:refs/heads/main or a specific environment. Keep the role's permissions narrow too.

57. Lambdas created in a loop

What does this print?

funcs = [lambda: i for i in range(3)]
print([f() for f in funcs])
  1. A.[2, 2, 2]
  2. B.[0, 1, 2]
  3. C.[0, 0, 0]
  4. D.It raises a NameError
Show answer

Answer: A. [2, 2, 2]

Each lambda looks up i when it is called, not when it is created, and by then the loop has finished with i equal to 2. This is called late binding. Capture the current value with a default argument, lambda i=i: i, to get [0, 1, 2].

58. Every task loads the last table

Three tasks are created in a loop. When they run, all three load "payments". Why?

for t in ["orders", "users", "payments"]:
    PythonOperator(
        task_id=f"load_{t}",
        python_callable=lambda: load_table(t),
    )
  1. A.task_id must not contain f-strings
  2. B.PythonOperator caches the first callable
  3. C.The lambda reads t when it runs, after the loop has ended
  4. D.Airflow runs only the last task created in a loop
Show answer

Answer: C. The lambda reads t when it runs, after the loop has ended

The lambda captures the variable t, not its value at that moment. The worker parses the file, the loop finishes with t = "payments", and only then is the lambda called. Pass the value explicitly with op_kwargs={"table": t} or a default argument.

59. Retries leaving extra files

An extract task writes s3://raw/orders/2026-03-05/part_<current_timestamp>.json. A retry wrote a second file, and the loader read both. What is the root fix?

  1. A.Have the loader read only the newest file in the folder
  2. B.Name files only from the run's date so retries overwrite
  3. C.Disable retries for the extract task
  4. D.Add the timestamp in milliseconds instead
Show answer

Answer: B. Name files only from the run's date so retries overwrite

A name based on the current time is new on every attempt, so retries add files instead of replacing them. Deriving the path only from the data interval, or clearing the folder before writing, makes the task idempotent.

60. Mocking a third-party SDK

Tests mock the AWS SDK's S3 client methods directly in 40 places. An SDK upgrade changes return shapes, all tests stay green, and production breaks. What is the better design?

  1. A.Mock the SDK in even more detail so that the mocks match every possible response
  2. B.Wrap the SDK in your own small adapter, mock that, and test the adapter against the real service
  3. C.Pin the SDK version forever so that its responses can never change
  4. D.Remove all tests that touch storage and rely on manual checks
Show answer

Answer: B. Wrap the SDK in your own small adapter, mock that, and test the adapter against the real service

Mocks of a library you do not own encode your guesses about its behaviour and drift silently. An adapter with your own interface keeps mocks meaningful, and a few integration tests of the adapter against the real service (or a faithful local emulator) catch upgrade breaks.

Ready to test yourself?

Take a 15-question AWS MCQ test with a score at the end, or practise the full AWS question bank and earn points on the leaderboard.