AWS EC2 interview questions and answers
AWS EC2 interview questions go one level below "use EC2 for compute": how to read an instance type, what survives a stop versus a terminate, EBS volumes versus instance store, security groups versus network ACLs, how user data and the instance metadata service work, and how Auto Scaling replaces unhealthy instances. Scenario rounds ask you to debug an instance you cannot reach or one that keeps failing health checks. Good answers name the exact layer you would check and why.
By Evin JohnPublished 7 min read
How EC2 questions are asked
EC2 is the service most cloud, DevOps, SRE and Linux administration interviews dig into, because it is where networking, storage, identity and the operating system meet. Broad service-selection and architecture questions are on AWS interview questions; this page stays on the virtual machine itself and the pieces wired to it. Expect a fast concept round, a design question such as spreading a fleet across zones, and at least one hands-on troubleshooting story.
- ConceptsInstance types, AMIs, EBS, security groups, key pairs, metadata and lifecycle states.
- DesignLay out subnets and an Auto Scaling group across Availability Zones, pick storage and a purchasing mix.
- TroubleshootingSSH times out, a status check fails, disk fills up, an instance has no internet, an app cannot read S3.
- Your experienceA real incident or cost problem on EC2 you handled, with the evidence you used.
EC2 fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| How do you read an instance type name? | Instance families | Family letter (general purpose, compute, memory, storage or accelerated), a generation number, optional letters for processor or features (for example g for AWS Graviton Arm processors, d for local NVMe storage), then a size. Newer generations usually give better price-performance. |
| What is an AMI? | Images | A template with a root volume snapshot, launch permissions and block device mapping. AMIs are regional; copy one to use it in another Region. |
| Stop, hibernate, reboot or terminate? | Lifecycle | Reboot keeps everything. Stop shuts down, keeps EBS volumes and usually moves the instance to new hardware on start. Hibernate also saves RAM to the root volume. Terminate deletes the instance and, by default, its root volume. |
| EBS versus instance store? | Storage | EBS is network-attached, persists independently of the instance and can be snapshotted. Instance store is physically attached, very fast, and its data is lost on stop, hibernate or hardware failure. |
| Security group versus network ACL? | Network security | Security groups attach to network interfaces, allow rules only and are stateful, so replies are allowed automatically. NACLs attach to subnets, have numbered allow and deny rules and are stateless, so return traffic needs its own rule. |
| What does user data do? | Bootstrapping | A script or cloud-init config passed at launch. By default it runs once, as root, on first boot. It is not a secret store, since anyone who can read instance attributes can read it. |
| How should an app on EC2 get AWS credentials? | Identity | An IAM role attached through an instance profile. The SDK fetches short-lived credentials from the metadata service and refreshes them; no keys on disk. |
| What is an Elastic IP? | Addressing | A static public IPv4 address you own in a Region and can move between instances. Most designs avoid needing one by putting a load balancer or DNS in front. |
| What is an ENI? | Networking | An elastic network interface: private IPs, security groups and a MAC address. A secondary ENI can be moved to a standby instance for some failover designs. |
| Shared, dedicated instance or dedicated host? | Tenancy | Shared runs on hardware other customers also use. Dedicated instances run on hardware reserved for your account. Dedicated hosts give visibility of sockets and cores, which matters for some per-core software licenses. |
Purchasing, capacity and storage questions
- How do you mix purchasing options for a web fleet? Cover the steady baseline with a commitment (Savings Plans or Reserved Instances), run peaks on On-Demand, and put interruption-tolerant work such as batch or CI on Spot. Exact discounts change, so talk in terms of fit, not percentages.
- What happens when Spot capacity is reclaimed? The instance gets a short interruption notice through metadata and EventBridge, then is stopped, hibernated or terminated. Design for it: checkpoints, queues, and diversified instance types across zones.
- What is a capacity reservation for? Reserving capacity for a type in one zone so a launch will not fail for lack of capacity, for example before a known event. It is about availability, separate from discount commitments.
- gp3 versus gp2 versus io2? gp2 ties IOPS to volume size; gp3 lets you set IOPS and throughput separately; io2 is provisioned IOPS for latency-sensitive databases. Throughput-optimized and cold HDD types suit large sequential reads.
- How do you grow a full EBS volume without downtime? Modify the volume size (Elastic Volumes), wait for the modification state, then grow the partition and file system inside the OS. Skipping the OS step is the classic mistake.
- How do EBS snapshots work? Point-in-time and incremental, stored regionally and copyable across Regions. Restored volumes load blocks lazily, so the first reads can be slow unless you initialize the volume or use fast snapshot restore.
- Can you attach one EBS volume to an instance in another zone? No. Volumes live in one Availability Zone; snapshot and restore into the other zone.
- What is EBS-optimized and why does it matter? Dedicated bandwidth between the instance and EBS so disk traffic does not compete with network traffic. Each type has its own EBS bandwidth ceiling, which can cap a database before CPU does.
Networking, metadata and security questions
import ipaddress
vpc = ipaddress.ip_network("10.20.0.0/16")
zones = ["a", "b", "c"]
blocks = vpc.subnets(new_prefix=20) # 16 blocks of /20
plan = {}
for tier in ("public", "private-app", "private-db"):
for z in zones:
plan[f"{tier}-{z}"] = next(blocks)
for name, net in plan.items():
usable = net.num_addresses - 5 # AWS reserves 5 addresses in every subnet
print(f"{name:14} {str(net):16} usable={usable}")
instance_ip = ipaddress.ip_address("10.20.37.14")
home = [n for n, net in plan.items() if instance_ip in net]
print("10.20.37.14 lives in", home[0])
print("spare /20 blocks left:", sum(1 for _ in blocks))
# public-a 10.20.0.0/20 usable=4091
# ... (nine subnets in total)
# private-db-c 10.20.128.0/20 usable=4091
# 10.20.37.14 lives in public-c
# spare /20 blocks left: 7TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
-H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/meta-data/instance-id
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/meta-data/placement/availability-zone- Why require IMDSv2? It needs a session token obtained with a PUT request, which blocks many server-side request forgery attacks that could only make simple GET requests to the metadata address and steal role credentials. Set it to required on launch templates and keep the hop limit low unless containers need more.
- Public subnet versus private subnet? A public subnet's route table sends 0.0.0.0/0 to an internet gateway, and instances there need a public IP to be reachable. Private subnets reach out through a NAT gateway or VPC endpoints.
- Cluster, spread and partition placement groups? Cluster packs instances close for low latency and high throughput (HPC). Spread puts each instance on distinct hardware for a few critical nodes. Partition groups racks into partitions for large distributed systems like Kafka or HDFS.
- How do you get a shell on an instance with no inbound ports? Systems Manager Session Manager, using the SSM agent and an instance role; access is audited and needs no SSH key or open port 22.
- What is the Nitro System? AWS's hypervisor and offload hardware that moves networking, storage and security work onto dedicated cards. It explains why newer types give more of the host to your workload and support features like enhanced networking.
- How do you encrypt EBS by default? Turn on account-level EBS encryption by default in each Region with a KMS key; new volumes and snapshot copies are then encrypted.
Auto Scaling and operations questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Launch template or launch configuration? | Fleet config | Launch templates are versioned, support mixed instance types and Spot, and are the current choice; launch configurations are legacy. |
| EC2 health checks versus ELB health checks in an Auto Scaling group? | Health | EC2 checks only see hardware and status checks. With ELB health checks enabled, the group also replaces instances the load balancer marks unhealthy, which catches a dead app on a live VM. |
| Which scaling policy would you use? | Scaling | Target tracking on a metric such as average CPU or requests per target for most web tiers; scheduled scaling for known peaks; step scaling for custom alarms. |
| What are lifecycle hooks for? | Graceful changes | Pausing an instance on launch to finish setup, or on termination to drain connections and ship logs before it goes. |
| How do you roll out a new AMI to a fleet? | Deployments | Update the launch template and run an instance refresh with a minimum healthy percentage, or blue/green behind the load balancer. |
| System status check versus instance status check? | Status checks | A system check failure is AWS hardware or network; stop and start to move hosts, or rely on automatic recovery. An instance check failure is inside your OS: kernel, file system, network config. |
| Scenario | Check in this order | Typical cause |
|---|---|---|
| SSH times out. | Public IP or route, security group inbound 22 from your IP, NACL in and out (ephemeral ports), OS firewall. | Instance in a private subnet, a NACL missing the return-port rule, or a security group limited to an old IP. |
| SSH says permission denied. | Key pair, user name for the AMI, file permissions on the key, authorized_keys. | Wrong default user for that AMI or a key that was rotated. |
| Instance status check fails after a reboot. | System log and instance screenshot from the console. | A bad fstab entry, a full root disk, or a kernel update that did not boot. |
| App cannot read S3: access denied. | Role attached? Policy allows the action and bucket? Bucket policy, KMS key policy, VPC endpoint policy. | Role missing or an explicit deny in one of the other policies. |
| CPU is low but the app is slow. | EBS volume metrics (queue length, burst balance), network allowance, memory and swap. | Storage throughput or IOPS ceiling, or a burstable instance out of credits. |
| Auto Scaling keeps launching and killing instances. | Health check grace period, target group health check path, user data logs. | App takes longer to start than the grace period, or the health endpoint fails. |
Fictional example
- Interviewer
- You launched an instance for a teammate and SSH just hangs. Walk me through it.
- Candidate
- A hang rather than a refusal tells me packets are not getting a reply, so I start with the network path, not the key. First, does it have a public IP and is its subnet's route table pointing 0.0.0.0/0 at an internet gateway? Then the security group: port 22 open from the address I am actually connecting from. Then the subnet's NACL, both inbound 22 and outbound to the ephemeral port range, since NACLs are stateless. If all that is fine I look at the instance screenshot and system log for a boot problem. And honestly, for a teammate I would rather attach an instance role and use Session Manager, so no port needs to be open at all.
EC2 practice plan
- Day 1: launch an instance with a role, user data and IMDSv2 required. Read metadata with the token and confirm a plain GET fails. Terminate it when done to avoid charges.
- Day 2: break access three ways (security group, NACL return rule, route) and fix each from the console and the CLI.
- Day 3: grow an EBS volume and extend the file system; take a snapshot and restore it in another zone.
- Day 4: build an Auto Scaling group behind a load balancer with ELB health checks, then deploy a broken AMI and watch replacement.
- Day 5: practice the lifecycle, storage and security group versus NACL answers out loud, then write the purchasing-mix answer without any numbers.
EC2 questions overlap with OS work; see Linux interview questions for the file system and process side. Self-managed platforms are a common EC2 workload: AEM interview questions covers author and publish tiers that teams have run on cloud VMs, and Alteryx interview questions touches the Windows servers analytics teams host for scheduled workflows.
Cloud troubleshooting answers are judged on order, and it is easy to jump to the key file before the route table. Natively, an AI interview assistant for Mac and Windows, keeps a transcript of your mock cloud round on your own computer so you can check the sequence you described. When you practice, it can read a console error or a policy snippet from a screenshot and suggest checks you skipped, and with Pro or the free trial it uses the résumé and job description you add. Transcripts and notes remain available afterward.
Questions people ask
What EC2 questions are asked in AWS interviews?
Instance type naming, AMIs and user data, stop versus terminate versus hibernate, EBS versus instance store, security groups versus NACLs, IAM roles, IMDSv2, placement groups, Auto Scaling and troubleshooting access.
What is the difference between a security group and a NACL?
Security groups attach to network interfaces, have allow rules only and are stateful. Network ACLs attach to subnets, have numbered allow and deny rules and are stateless, so return traffic needs its own rule.
What happens to data when an EC2 instance stops?
EBS volumes keep their data. Instance store data is lost on stop, hibernate or hardware failure. Terminating deletes the root EBS volume by default.
How do I answer an EC2 troubleshooting question?
Name the layers in order: route and public IP, security group, NACL, then the OS and application, and say what evidence you would read at each step.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
