[Cloud Fundamentals Part 3] Compute, Part 1: EC2, Nitro and Graviton, Reading Instance Types and Families, AMIs and Launch Templates, EBS and Instance Store, Session Manager and IMDSv2

Cloud Fundamentals Part 3 Compute, Part 1: EC2, Nitro and Graviton, Reading Instance Types and Families, AMIs and Launch Templates, EBS and Instance Store, Session Manager and IMDSv2 Cloud

“Instance type names for EC2 like m7i.large, c8g.xlarge, and r6a.2xlarge look like a code to me, and I can’t tell which one to choose. The on-premises VM I want to move is 2 vCPUs and 8 GB.”
“Is there a way to sign in to an EC2 instance in a private subnet without opening SSH port 22 to the internet?”

In Part 2, we looked at the big picture of AWS, including Regions, AZs, and the structure of pricing. From here, we go through the services one by one. First is EC2, the closest thing to a VM on your on-premises virtualization platform, and the compute services around it. The way you think about VMs carries over as is, but three things differ from on premises: you can create and discard instances at will, billing changes between stopping and terminating, and signing in and handling credentials work differently.

Parts 3 and 4 cover compute. In Part 3, the first half, we cover the foundation of EC2 and instance types, AMIs and launch templates, storage, ways to sign in, and IMDS.


What is EC2 (Elastic Compute Cloud)?

EC2 is the AWS virtual server service, and it is the closest thing to a “VM on a virtualization platform” on premises. When you launch an instance (a VM), you specify the AMI (an OS image), the instance type (CPU, memory, and network performance), the subnet to place it in, a security group, storage (EBS), and a key pair for signing in.

Everything above the OS is managed by you, which makes it IaaS (the shared responsibility in Part 1), so you apply patches and install monitoring agents yourself. The decisive differences from on premises are that launching, stopping, and deleting finish in tens of seconds to a few minutes with a single API call, and stopping an instance stops the charge for the instance itself, and that you can replicate instances with the same configuration any number of times from the same AMI. This idea of a “disposable server” is the premise for the Auto Scaling covered in Part 4 and for immutable infrastructure (rebuilding servers rather than repairing them).

Diagram with an upper blue frame "Subnet (belongs to one AZ)" containing a red dotted "Security group," inside which an "EC2 instance m7i.large" has three layers from top to bottom, "Application," "Guest OS (Amazon Linux 2023, etc.)," and "2 vCPU / 8 GiB / EBS bandwidth," with the text "From the OS up, managed by the customer (IaaS)" below. On the left, arrows enter the instance from "AMI (template)" with "Launch" and from "Key pair" with "SSH/RDP," and arrows leave the instance to "EBS" with "Block attach" and to "ENI" with "Private IP" on the right. A lower frame "A disposable server" shows the flow "Launch" → (one API call) → "Running and monitored" → (per-second billing stops) → "Stopped" → "Terminated and deleted," and three lines: "Launches in tens of seconds to minutes; stopping stops the instance charge (EBS continues)," "Replicate the same configuration any number of times from the same AMI → the premise for Auto Scaling and immutable infrastructure," and "Change your thinking from the on-premises 'server you nurture' to the 'server you rebuild.'"
  • EC2 is the AWS VM. From the OS up, the customer manages it (IaaS)
  • At launch, you specify the AMI, type, subnet, SG, EBS, and key pair
  • “Can be created in minutes and discarded” is the premise for Auto Scaling and more

The foundation of EC2: the Nitro System and Graviton

This is about EC2’s physical hosts and CPUs. It also matters when you read instance type names.

  • Nitro System: the foundation of EC2 since 2017 (C5). It offloads storage (EBS), networking (ENA), and security (the Nitro Security Chip) processing to dedicated cards (Nitro Cards), so nearly all of the host’s CPU goes to VMs. The hypervisor is a lightweight, KVM-based one
  • Effects: near-physical performance even in a VM, bare metal instances (*.metal), and a design in which even AWS operators cannot access a VM’s memory. AWS also offers Nitro Enclaves, which create an isolated execution environment inside a VM to handle confidential processing
  • Graviton: ARM (AArch64) CPUs that AWS designs itself. They have evolved from Graviton2 (2020) to 3, then 4 (2024, m8g and others), then 5 (2026, m9g; available Regions are expanding in stages). They are up to 20% cheaper than comparable x86 instances (the official wording; at the Graviton2 announcement, AWS said price performance was up to 40% better). Most Linux workloads run as is, but x86-only binaries and old commercial software do not run, so check before you migrate
  • The attribute letter in the instance type name (after the generation number) tells you the CPU: i = Intel, a = AMD, g = Graviton
  • It helps to think of this as applying the idea of handing TCP processing to the NIC (offloading such as TOE) to the whole platform
Diagram. The upper part is a "Physical host (Nitro System)" frame with three boxes, "VM: guest OS (customer)," "VM: guest OS (another customer)," and "Bare metal *.metal: directly, no hypervisor," above a "Nitro hypervisor (KVM-based, lightweight)," below which are "Nitro Card: EBS," "Nitro Card: ENA (network)," and "Nitro Security Chip," with the text "Storage, network, and security processing is offloaded to dedicated cards → the host CPU goes almost entirely to VMs. Even AWS operators cannot access VM memory. The isolated execution environment is Nitro Enclaves." The lower part, "Choosing a CPU (attribute letter in the type name)," lists "i = Intel Xeon," "a = AMD EPYC," and "g = Graviton (ARM)," with "Graviton2 (2020) → 3 → 4 (2024, m8g, etc.) → 5 (2026, m9g). Up to 20% cheaper than comparable x86 (official). Most Linux runs as is, but x86-only binaries and old commercial software do not → check before migrating."

How to read instance types

Instance type names follow a rule, and once you can read them you can estimate performance.

  • The notation is family + generation + attribute . size. Examples: m7i.large, c8g.xlarge, r6a.2xlarge, t4g.micro
  • Family: purpose (m = general purpose, c = compute, r = memory, t = burstable, i/d = storage, p/g/inf/trn = GPUs and AI accelerators)
  • Generation: the bigger the number, the newer. At the same size, a newer generation is often faster and cheaper, so choose the newest generation you can
  • Attribute: g = Graviton, i = Intel, a = AMD, n = enhanced networking, d = local NVMe, e = extra memory and storage, flex = a lower-priced version with reduced baseline performance (m7i-flex)
  • Size: large = 2 vCPUs as the baseline, xlarge = 4, 2xlarge = 8, and so on, doubling each step. Memory follows a per-family ratio (m is 4 GiB/vCPU, r is 8, c is 2)
  • For many types, a vCPU is one hyper-thread (on Intel and on AMD up to the 6th generation, 2 vCPUs = 1 physical core). On Graviton and 7th-generation AMD (m7a, c7a, r7a), 1 vCPU = 1 physical core
Diagram with five boxes in a row at the top, "m," "7," "i," ".," and "large," with explanations "Family (general purpose)," "Generation (newer is faster and cheaper)," "Attribute (Intel)," and "Size (2 vCPU, 8 GiB)." In the middle, the "Family" frame has eight boxes: "M General purpose 1:4 GiB," "C Compute 1:2 GiB," "R Memory 1:8 GiB," "T Burstable, credit-based," "I / D Local SSD / HDD," "P / G / Inf / Trn GPUs and AI chips," "Hpc High-bandwidth NW," and "X / z Large memory." The "Attribute letters" frame reads "g Graviton / i Intel / a AMD / n Enhanced networking / d Local NVMe / e Extra memory and storage / flex Lower-priced version (m7i-flex)," and the "Size" frame reads "large = 2 vCPU → xlarge = 4 → 2xlarge = 8 ... doubling. For many types, a vCPU is one hyper-thread (on Intel and AMD up to 6th generation, 2 vCPUs = 1 physical core). On Graviton and 7th-generation AMD (m7a, c7a, r7a), 1 vCPU = 1 core."

Instance family overview

The characteristics and uses of each family.

FamilyCharacteristicsExamplesUses
General purpose MCPU:memory = 1:4 GiBm7i, m8gWeb and application servers, small databases
Burstable TLow baseline plus CPU credits for bursts. Cheapt3, t4gDevelopment environments, low-load servers. Note that performance drops once the credits run out
Compute C1:2 GiB. High clock speedc7i, c8gBatch jobs, encoding, game servers
Memory R / X / z1:8 GiB or morer7i, r8g, x2idnIn-memory databases, SAP HANA, large caches
Storage I / DLocal NVMe SSD / HDDi4i, i8g, d3NoSQL, distributed file systems, data warehouses
Accelerators P / G / Inf / TrnGPUs, chips for inference and trainingp5, g6, inf2, trn2Machine learning, video processing
HPC HpcHigh-bandwidth networking (EFA)hpc7aNumerical computation

If you are unsure, start with the newest generation of M (general purpose), then look at CloudWatch metrics and move toward C or R. “Big to be safe” goes against the cost optimization pillar of the Well-Architected Framework (Part 13).

That is the first question at the start. Read the name as “family + generation + attribute . size.” m7i.large is general purpose, 7th generation, Intel, with 2 vCPUs (8 GiB); c8g.xlarge is compute, 8th generation, Graviton, with 4 vCPUs (8 GiB); and r6a.2xlarge is memory, 6th generation, AMD, with 8 vCPUs (64 GiB). For a VM with 2 vCPUs and 8 GB, the CPU-to-memory ratio is 1:4, so start with a large size of M (m7i.large, or Graviton’s m8g.large if you have no x86-only software), run it, then look at the metrics and move toward C or R.


AMIs (Amazon Machine Images) and choosing an OS

An AMI is the template for launching EC2, and it contains the OS and, if needed, pre-installed middleware and settings. The standard AMIs AWS provides include Amazon Linux 2023, Ubuntu, RHEL, SUSE, and Windows Server 2019/2022/2025, and Windows is offered at an hourly price that includes the OS license.

Amazon Linux 2023 is Fedora-based, uses dnf and systemd, requires IMDSv2 (see the later section “The Instance Metadata Service (IMDS)”), and defaults to SELinux permissive, so operating it differs from the older Amazon Linux 2. Amazon Linux 2 reached end of support on June 30, 2026 (there is no extended support; AL2023 is supported until June 2029).

A “custom AMI,” made from an instance you configured yourself, is the same idea as an on-premises golden image, and it is this AMI that Auto Scaling replicates. AMI IDs differ by Region (even for the same Ubuntu, the ami- ID is different in Tokyo and Osaka), so you need to copy the AMI to use it in another Region. For Marketplace AMIs (virtual appliances such as Fortinet and Palo Alto), the software fee is added to the AWS usage charge.

Diagram. In the upper "AMI types" frame, three boxes, "Standard AMI: AL2023, Ubuntu, RHEL, Windows," "Custom AMI: made from a configured instance," and "Marketplace AMI: Fortinet, etc. (software fee added)," lead by a "Launch (template)" arrow to "Launch EC2" and by another arrow to "Auto Scaling replicates from the same AMI." The middle "Amazon Linux 2023 (current)" frame reads "Fedora-based, dnf and systemd, IMDSv2 required, SELinux permissive by default. The older Amazon Linux 2 reached end of support on 2026-06-30 (no extension). Windows Server 2019 / 2022 / 2025 is an hourly price including the license." The lower "AMI IDs are Region-specific" frame reads "ami-0abc (Tokyo) ≠ ami-0def (Osaka). Copy the AMI to use it in another Region. The golden image idea carries over as is."
  • An AMI is a template of OS plus settings. Standard AMI / custom AMI / Marketplace AMI
  • Amazon Linux 2023 is current. AL2 reached end of support on 2026-06-30 (no extension)
  • AMI IDs are Region-specific. It is the source for Auto Scaling replication

Launch templates and user data (cloud-init)

These are the mechanisms for creating instances with the same configuration over and over.

  • Launch template: saves the AMI, instance type, SG, key pair, user data, tags, and more together, and manages them by version. It is the configuration source for Auto Scaling (Part 4). The older “launch configurations” can no longer be newly created from the console in accounts created on or after June 1, 2023, or by any method in accounts created on or after October 1, 2024
  • User data: a script run at first boot. On Linux, cloud-init processes it, and if it starts with #!/bin/bash it runs as a shell script as root. On Windows, EC2Launch v2 runs the <powershell> block
  • By default it runs only at first boot. To make it run again on stop → start, you need to change the cloud-init settings
  • User data can be read by anyone through IMDS (see the later section), so never write passwords or access keys in it (use Secrets Manager; Part 9)

As an example, here is user data that installs a web server at first boot.

#!/bin/bash
dnf install -y nginx
systemctl enable --now nginx
Diagram. In the upper pink frame "Launch template (versioned)," five example settings are listed: "AMI: ami-0abc... (AL2023)," "Instance type: m7i.large," "SG: sg-web / Key pair: none (Session Manager)," "User data: #!/bin/bash ...," and "Tags: Environment=prod, System=ec-site." Arrows from the frame lead to "Auto Scaling" and "Manual launch / Spot Fleet." In the middle frame "User data (runs only at first boot)" are three lines, "#!/bin/bash," "dnf install -y nginx," and "systemctl enable --now nginx," plus "Linux: cloud-init runs it as root," "Windows: EC2Launch v2 runs the <powershell> block," and "To re-run on stop → start, change the cloud-init settings." In the lower red "Prohibited" frame: "Anyone can read it from IMDS → do not write passwords or access keys (Secrets Manager → Part 9)."

EC2 storage: EBS and instance store

The block storage you use with EC2 comes in two kinds: EBS, attached over the network, and instance store, attached directly to the host.

ItemEBSInstance store
What it isBlock storage attached over the network (Part 5, “EBS volume types”)NVMe / SATA attached directly to the host
PersistenceRemains when the instance is stopped or terminated (the root volume is deleted on termination by default)Lost on stop, termination, or host failure
PerformanceChosen by type (gp3 starts at 3,000 IOPS)Very high (hundreds of thousands of IOPS)
Supported typesAllOnly the d / i attributes and some large sizes
UsesOS, databases, almost everythingScratch space, caches, distributed file systems that replicate on their own
BillingProvisioned GB-monthsIncluded in the instance price

In terms of on-premises storage categories, EBS takes the position of SAN (block), and instance store corresponds to DAS. EBS can be attached only within a single AZ, so to move it to an instance in a different AZ, you copy it through a snapshot.


Ways to sign in to an instance

To sign in to EC2, besides SSH keys, there are methods that do not open any ports.

  • Key pair + SSH (22/tcp): the public key you specified at launch is placed in ~/.ssh/authorized_keys. The key is RSA or ED25519. The private key is not kept by AWS, so if you lose it, you cannot sign in as is. If you lose it, recover through Session Manager or an AMI
  • EC2 Instance Connect: pushes a temporary public key (valid for 60 seconds) through the API and then connects by SSH. You do not need to distribute keys. With EC2 Instance Connect Endpoint (2023), you can connect to a private subnet without a public IP or a bastion host
  • Systems Manager Session Manager (Part 11): goes through the SSM agent. It opens no inbound ports at all, authenticates with IAM, and can record operation logs in S3 or CloudWatch. It is the method AWS recommends, and it removes the need for a bastion server
  • Windows: RDP (3389/tcp). You get the administrator password by decrypting it with the key pair’s private key. You can also use an RDP tunnel through Session Manager
  • Serial console: on Nitro-based instances, you can connect to the OS console when an instance no longer boots
  • In practice today, avoid the setup of “opening 22 to the whole world in the SG,” and make Session Manager or Instance Connect Endpoint your first choice

That is the second question at the start. With Session Manager, the SSM agent on the instance only makes outbound connections, so you can sign in without opening port 22.

Diagram. In the upper part, an "IAM authentication" line runs from "Operator" on the left into a blue "Private subnet (port 22 not open)" frame inside the purple "VPC" frame, splits to "Session Manager" and "Instance Connect Endpoint," and from each an arrow leads to "EC2 (SSM agent)." The Session Manager side reads "Outbound only from the agent," and the Instance Connect Endpoint side reads "SSH / RDP." Below the subnet are a "Key pair RSA / ED25519" box and "The private key is not kept by AWS. If lost, recover via SSM or an AMI." In the lower "Recommended order" frame: in green, "1. Session Manager: no ports, IAM, audit logs"; in blue, "2. Instance Connect Endpoint: temporary public key valid 60 seconds, no bastion"; in red, "3. Direct SSH (port 22): do not open to 0.0.0.0/0."

The Instance Metadata Service (IMDS)

IMDS is the mechanism an instance uses to get information about itself (instance ID, AZ, private IP, temporary credentials for the IAM role, and user data), and you query it over HTTP at the link-local address 169.254.169.254. The 169.254.0.0/16 range is used for this.

If you attach an IAM role (Part 8) to an instance, an application can get access keys from IMDS, so you do not need to put keys in files. However, the old IMDSv1 responds to a simple GET, so there have been incidents in which credentials were stolen from outside through a web application with an SSRF vulnerability (the 2019 Capital One incident is famous).

The countermeasure, IMDSv2, is a method in which you first get a token with a PUT and then make a GET with that token in a header, and the hop limit (1 by default) also prevents retrieval across NAT. Amazon Linux 2023 and recent launch paths (the console quick start, and instance types released in 2024 or later) default to IMDSv2 only, and it is recommended to change existing instances to require v2 as well.

$ TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
    -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")      # IMDSv2: get a token first
$ curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
    http://169.254.169.254/latest/meta-data/instance-id
i-0123456789abcdef0
$ aws ec2 describe-instances \
    --query "Reservations[].Instances[].MetadataOptions.HttpTokens"   # if it is required, v2 is mandatory
$ aws ec2 modify-instance-metadata-options \
    --instance-id i-0123456789abcdef0 --http-tokens required          # require v2 on an existing instance
Diagram. In the upper "EC2 instance" frame, an arrow "GET http://169.254.169.254/latest/meta-data/..." runs from "App / SDK" to "IMDS," with the response "Instance ID, AZ, private IP, user data, temporary credentials for the IAM role." In the middle left, a red "IMDSv1 (old)" frame reads "Responds to a simple GET" and "Credentials stolen from outside through a web app with an SSRF vulnerability (2019 Capital One)." In the middle right, a green "IMDSv2 (recommended, default)" frame reads "Get a token with PUT → GET with a header," "Hop limit 1 (not reachable across NAT)," and "AL2023, quick start, and new types from 2024 onward: v2 only." In the lower part, an arrow from "IAM role (instance profile)" reading "Issued by STS → received through IMDS" leads to "Temporary credentials," with the text "Do not put access keys in files or AMIs. Change existing instances to require v2 too (modify-instance-metadata-options)."
  • Get your own information and the temporary credentials for the IAM role at 169.254.169.254
  • IMDSv1 can be stolen through SSRF. Make IMDSv2 (the token method) required
  • How to check: aws ec2 describe-instances --query "...MetadataOptions.HttpTokens"

References

These are the official documents that correspond to this part (checked in November 2026). Prices, limits, and availability can change, so check the latest content before you use them.


Think about it

  1. Pick one server you run on premises today, and think about which family, M, C, or R, it corresponds to from its CPU-to-memory ratio, and whether it could move to Graviton (whether it has any x86-only software).
  2. If you had an EC2 instance with port 22 open to the internet, what would you need in order to move it to Session Manager (the SSM agent, an IAM role, and a route for outbound traffic)?
  3. Check whether any existing instance has HttpTokens still set to optional, and think about whether any application would be affected if you changed it to require v2.

Hint: For 1, review “How to read instance types” and “The foundation of EC2: the Nitro System and Graviton”; for 2, “Ways to sign in to an instance”; and for 3, “The Instance Metadata Service (IMDS).”


Summary

  • EC2 is the AWS VM, and from the OS up, the customer manages it. “Can be created in minutes and discarded” is the premise for Auto Scaling and more
  • The underlying Nitro hands processing to dedicated cards, and Graviton (ARM) has high price performance but does not run x86-only software
  • Read an instance type as “family + generation + attribute . size,” and if unsure, start with the newest generation of M
  • AMIs and launch templates let you create the same configuration any number of times. Do not write secrets in user data
  • Instance store is lost on stop or termination. Put the OS and databases on EBS
  • Make Session Manager or Instance Connect Endpoint your first choice for signing in. Do not open 22 to the whole world
  • IMDS is the mechanism that hands over the IAM role’s temporary credentials. Make IMDSv2 required

Next time, we cover stopping, termination, and billing, purchase options, Auto Scaling, ELB, containers, Lambda, how to choose among them, and the Azure equivalents.


The Cloud Fundamentals series (14 parts)

All 14 parts with a reading guide: Cloud Fundamentals

  1. What Is the Cloud?
  2. The big picture of AWS
  3. Compute, part 1 (EC2, Nitro, instance types, AMIs, IMDS) (this article)
  4. Compute, part 2 (pricing and purchase options, Auto Scaling, ELB, containers, Lambda)
  5. Storage
  6. Networking, part 1 (VPC, subnets, security groups, NACLs)
  7. Networking, part 2 (DNS, connectivity, Route 53, CloudFront)
  8. IAM and security, part 1 (IAM, policies, STS, federation, Organizations)
  9. IAM and security, part 2 (KMS, secrets, ACM, detection and protection)
  10. Databases
  11. Operations, monitoring, and cost, part 1 (CloudWatch, CloudTrail, Config, SSM)
  12. Operations, monitoring, and cost, part 2 (tags, data transfer, cost management, Control Tower, IaC)
  13. The Well-Architected Framework
  14. Mapping earlier topics to AWS, and a wrap-up

This series is the English edition of 【クラウド入門】, originally written in Japanese.

コメント

Copied title and URL