# EC2 Instances, AMIs and Pricing Options

> Launch and size EC2 instances, choose AMIs and instance families, bootstrap with user data and understand On-Demand, Spot and Savings Plans pricing. Free...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals
Last updated: 2026-11-28

Launch and size EC2 instances, choose AMIs and instance families, bootstrap with user data and understand On-Demand, Spot and Savings Plans pricing.

Beginner · about 6 hours · difficulty 2/5

Learn first: [NAT Gateways, Security Groups and NACLs](https://www.internhack.in/roadmaps/tracks/cloud-engineer/nat-security-groups)

**Amazon EC2** gives you virtual machines. It is the most basic AWS compute service and still runs a huge share of real workloads. Azure Virtual Machines and Google Compute Engine are the equivalents.

### Instance types

Names like **t3.micro** or **m7g.large** encode family, generation, options and size:

- **t** burstable general purpose (good for small, spiky apps; watch CPU credits).
- **m** balanced, **c** compute optimized, **r** memory optimized, **g/p** GPU.
- A **g** after the generation number (m7g) means **Graviton** (ARM), usually cheaper for the same performance.

### AMIs and bootstrapping

- An **AMI** is the disk image the instance boots from (Amazon Linux 2023, Ubuntu, Windows, or your own).
- **User data** runs a script on first boot to install packages and start your app.
- **Golden AMIs** (built with EC2 Image Builder or Packer) make launches faster and repeatable.

### Pricing options

- **On-Demand**: pay per second, no commitment.
- **Savings Plans / Reserved Instances**: commit for 1 or 3 years for large discounts.
- **Spot**: spare capacity at up to 90 percent off, but AWS can reclaim it with a two-minute warning. Great for batch jobs and CI runners.
- **Dedicated Hosts**: for licensing or compliance needs.

### Pitfalls

- Picking a large instance "to be safe" and paying for idle CPU.
- Running production on a t-family instance that runs out of CPU credits under steady load.
- Losing data on **instance store** volumes, which are wiped when the instance stops.

You are ready to move on when you can launch an instance with a user data script that installs a web server, and explain which pricing model fits a web app, a nightly batch job and a database.

## Key concepts

- **Instance families and sizes**
- **Graviton (ARM) instances**
- **AMIs**
- **User data bootstrapping**
- **Key pairs**
- **On-Demand, Spot, Savings Plans**
- **Instance store vs EBS**
- **Golden AMIs with Image Builder or Packer**

## Mini project

Launch a free-tier eligible instance in Mumbai with a user data script that installs nginx and writes the instance ID into the page. Access it in a browser, then create an AMI from it and launch a second copy. Terminate both instances and deregister the AMI and its snapshot afterwards to stay within free tier.

## Check yourself

You have a nightly video-encoding job that can be retried if interrupted. Which EC2 pricing option would you pick and why?

## Free resources

- [Amazon EC2 documentation](https://docs.aws.amazon.com/ec2/) (AWS)
- [Amazon EC2 instance types](https://aws.amazon.com/ec2/instance-types/) (AWS)
- [Amazon EC2 Spot Instances](https://aws.amazon.com/ec2/spot/) (AWS)

Previous: [Route 53 and CloudFront at the Edge](https://www.internhack.in/roadmaps/tracks/cloud-engineer/route53-cloudfront) · Next: [Operating EC2 with Systems Manager](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-operations)

## More in Compute: EC2, Auto Scaling and Load Balancing

- [EC2 Instances, AMIs and Pricing Options](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals)
- [Operating EC2 with Systems Manager](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-operations)
- [Elastic Load Balancing: ALB and NLB](https://www.internhack.in/roadmaps/tracks/cloud-engineer/load-balancers)
- [Auto Scaling Groups and Launch Templates](https://www.internhack.in/roadmaps/tracks/cloud-engineer/auto-scaling)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
