Chapter 5: Amazon EC2 (Elastic Compute Cloud)
Interview Questions
- Q1. What is an AMI?
- An Amazon Machine Image is a template containing the OS, software and configuration (backed by EBS snapshots) used to launch EC2 instances.
- Q2. What is a security group? Is it stateful?
- A virtual firewall at the instance/ENI level with allow rules for inbound and outbound traffic. It is stateful — return traffic for an allowed connection is automatically allowed.
- Q3. What is the difference between stopping and terminating an instance?
- Stop shuts it down and keeps the EBS root volume (auto public IP is released, EBS still billed). Terminate deletes the instance permanently and, by default, its root volume.
- Q4. Explain EC2 pricing models.
- On-Demand (pay per second, no commitment), Savings Plans and Reserved Instances (commitment for big discounts), Spot (spare capacity, up to ~90% off, can be interrupted), Dedicated Hosts/Instances (physical isolation).
- Q5. How do you connect to a Linux EC2 instance from Windows?
- Using the built-in OpenSSH client (
ssh -i key.pem user@IPafter fixing key permissions with icacls), PuTTY with a .ppk key, MobaXterm, EC2 Instance Connect or Session Manager. - Q6. What is user data?
- A script passed at launch that runs automatically (as root, via cloud-init) on the first boot — used to install packages or configure the server.
- Q7. What is the instance metadata service?
- An endpoint at 169.254.169.254 inside each instance that returns metadata like instance ID, IPs, AZ and IAM role credentials. IMDSv2 requires a session token.