TechEarl

How to Change an AWS EC2 Instance Type (Resize Without Data Loss)

Stop the instance, modify the instance type, start it. The exact gcloud-equivalent AWS CLI syntax, the compatibility matrix for moving between families and generations, the Nitro vs Xen gotcha, the instance-store data-loss trap, and the production sequence (snapshot AMI, scale out, replace) that gets you to a new instance type with zero downtime.

Ishan KarunaratnePublished ⏱️ 24 min readUpdated
Share thisCopied
Change an EC2 instance type without data loss: stop the instance, run aws ec2 modify-instance-attribute, start it again. Covers Nitro vs Xen compatibility, ENA and NVMe driver requirements, the instance-store ephemeral-data trap, and the zero-downtime ASG rolling-replace pattern.

To change an EC2 instance type on an EBS-backed instance, stop it, modify the type, then start it: aws ec2 stop-instances --instance-ids i-0abc, aws ec2 modify-instance-attribute --instance-id i-0abc --instance-type '{"Value": "t3.large"}', aws ec2 start-instances --instance-ids i-0abc. It takes under a minute and the EBS volumes, security groups, and IAM role all survive.

Changing an EC2 instance type is one of those operations that looks trivial in the console (stop, edit, start) and yet bites people in three places: an instance-store volume that evaporates the moment you stop the instance, a Xen-era AMI that refuses to boot on a Nitro host, and a production fleet that takes the wrong kind of downtime because nobody set up an Auto Scaling Group with a rolling replace. This post is the full procedure for an EBS-backed instance, the CLI one-liners, the compatibility rules that decide whether the resize succeeds or fails, and the zero-downtime pattern I reach for on anything customer-facing.

How do I change an AWS EC2 instance type?

For an EBS-backed instance the procedure is three calls. Stop the instance: aws ec2 stop-instances --instance-ids i-0abc. Modify the type: aws ec2 modify-instance-attribute --instance-id i-0abc --instance-type '{"Value": "t3.large"}'. Start it again: aws ec2 start-instances --instance-ids i-0abc. The whole thing takes under a minute and the EBS root volume, attached EBS data volumes, security groups, IAM role, and Elastic IP all survive. The instance ID stays the same; the public IPv4 will change unless you use an Elastic IP. Instance-store volumes are wiped on stop and the resize requires migration to a fresh instance (snapshot the EBS root to an AMI, launch a new instance from the AMI on the new type). The destination type must be compatible with the AMI's architecture (x86_64 vs arm64), virtualization (HVM vs PV), network driver (ENA), and storage driver (NVMe). Modern Nitro families (C5/M5/R5/T3 and later) require ENA + NVMe; older Xen families do not. Moving from Xen to Nitro on an AMI that lacks those drivers fails at boot.

Try it with your own values

Type your AWS values once, every example below uses them.

Jump to:

Before you start: the four pre-flight checks

Four things to confirm before you touch the instance, in increasing order of how badly people get burned by missing them.

1. The root volume is EBS, not instance store. Instance store volumes are ephemeral local SSDs physically attached to the host. Stopping an instance-store-backed instance wipes the volume permanently. Check with:

bash
aws ec2 describe-instances --region :region --instance-ids :instance_id \
  --query 'Reservations[].Instances[].RootDeviceType'

ebs is fine. instance-store means the standard stop-modify-start path is not available; see Method 3.

2. Anything important on the instance store is backed up. Even on EBS-rooted instances, larger families (m5d, r5d, i3, c5d) come with instance-store volumes attached as /dev/nvme1n1, /dev/nvme2n1, etc. Anything on those volumes is gone when you stop the instance. Snapshot or rsync the data first.

3. The destination instance type is in the same family architecture. x86_64 AMIs cannot boot on arm64 (Graviton) instances and vice versa. Check the AMI's architecture:

bash
aws ec2 describe-images --region :region --image-ids ami-0abc \
  --query 'Images[].Architecture'

If you want to move from x86 to Graviton (or vice versa), you have to rebuild the image on the target architecture and migrate, not resize.

4. The AMI has the drivers the destination type requires. Nitro instance types (C5, M5, R5, T3, M6, C6, R6, M7, C7, and every newer family) require both ENA (network) and NVMe (block storage) drivers in the AMI. AMIs built before 2018 or based on legacy distributions may lack them. Check:

bash
aws ec2 describe-instances --region :region --instance-ids :instance_id \
  --query 'Reservations[].Instances[].EnaSupport'

true means the network driver is loaded. For NVMe, run lsmod | grep nvme inside the instance before stopping it. If either is missing, the instance starts on the new type but fails to attach storage or come up on the network; you get a failed status check and have to revert.

Take a snapshot of the EBS root before you do anything destructive:

bash
aws ec2 create-snapshot --region :region --volume-id vol-0abc \
  --description "pre-resize-$(date +%Y%m%d-%H%M)"

Snapshots are incremental, and creating one is asynchronous: it captures the volume as it was at the moment of the request, then stays pending while the changed blocks are copied to S3, which can take from minutes to several hours. You can keep using the volume while it is pending. AWS recommends stopping the instance before snapshotting a root volume, so for the cleanest copy take it right after the stop-instances step below. It is the only single-command rollback you have.

Method 1: Stop, modify, start (the standard path)

The three CLI calls, in order:

bash
aws ec2 stop-instances --region :region --instance-ids :instance_id

Wait for the state to settle:

bash
aws ec2 wait instance-stopped --region :region --instance-ids :instance_id

Modify the type:

bash
aws ec2 modify-instance-attribute \
  --region :region \
  --instance-id :instance_id \
  --instance-type '{"Value": ":new_type"}'

The JSON quoting is awkward but exact. The CLI accepts the shorthand --instance-type t3.large on many recent versions too, but the documented form is the JSON Value wrapper and it works on every CLI v1 and v2 release since 2013.

Start the instance again:

bash
aws ec2 start-instances --region :region --instance-ids :instance_id
aws ec2 wait instance-running --region :region --instance-ids :instance_id

Verify the new type:

bash
aws ec2 describe-instances --region :region --instance-ids :instance_id \
  --query 'Reservations[].Instances[].InstanceType'

Total wall-clock time on a typical EBS-rooted instance: 60 to 90 seconds. The instance ID is unchanged. The Elastic IP, if any, reattaches automatically. EBS volumes stay attached with the same block device mappings. On Nitro types the Linux NVMe device name (/dev/nvme1n1 and so on) follows discovery order and can change between starts, so mount by filesystem UUID or label, not by device name. Security groups, IAM instance profile, key pair, user data, and tags all persist.

If the destination type is not compatible (Xen-only AMI on a Nitro family, or a c5n that requires ENA when the AMI lacks it) start-instances returns the instance to running but the status check fails. Revert with the same sequence in reverse: stop, modify back to the original type, start.

Method 2: Console click-path

For the rare one-off where you don't want to type the CLI. EC2 → Instances → select the instance → Instance state → Stop instance. After it shows Stopped, Actions → Instance settings → Change instance type. Pick the new type from the dropdown. Save. Instance state → Start instance.

The console enforces the same compatibility rules as the CLI and refuses incompatible types with a slightly more readable error. Useful for exploring what types are available in the current region and AZ.

Compatibility: what can move to what

Not every type can move to every other type without rebuilding the AMI. The rules:

ConstraintRuleWhat happens if violated
AMI architecturex86_64 → x86_64, arm64 → arm64Instance fails to boot; status check 1/2 fail
VirtualizationHVM → HVM only (PV is end-of-life)New type rejects the AMI at launch
ENA supportRequired for c5, m5, r5, t3, m6, c6, r6, and every newer familyInstance starts but has no network
NVMe supportRequired for Nitro families (same list as ENA)Instance starts but cannot mount root EBS
TenancyDedicated host families cannot move to shared tenancy and vice versaAPI error before stop completes
Placement groupCluster placement requires compatible types (10 Gbps capable)API error on start
Family-specific featuresEFA (HPC), Local Zones, WavelengthValidation error on modify

The good cases: same family generation (t3.medium → t3.large), within a Nitro generation across families (m5.large → c5.large → r5.large), bumping a generation within an architecture (m5.large → m6i.large). The bad cases: old Xen family (m3, c3, m4, c4) to Nitro family on an AMI without ENA / NVMe; x86 to arm64 without rebuilding the image.

The safe play for any non-trivial jump is the snapshot-AMI-and-relaunch path in Method 3. It costs ten extra minutes but eliminates the "instance boots but has no network" failure mode.

Method 3: Snapshot AMI + relaunch (Xen to Nitro, instance-store)

When the destination type isn't compatible with the current AMI, the fix is to bake a new AMI from the running instance with ENA and NVMe enabled, then launch a fresh instance from that AMI on the new type. This is also the procedure for instance-store-rooted instances where stop-modify-start isn't available.

Step 1: Make sure ENA and NVMe modules are loaded inside the instance (Amazon Linux 2 / 2023, Ubuntu 18.04+, RHEL 7.4+ all ship them):

bash
sudo modprobe ena
sudo modprobe nvme
lsmod | grep -E "ena|nvme"

Step 2: Create an AMI from the running instance. With --no-reboot the instance stays up and the snapshots are crash-consistent only:

bash
aws ec2 create-image \
  --region :region \
  --instance-id :instance_id \
  --name "migration-$(date +%Y%m%d-%H%M)" \
  --description "Pre-Nitro migration" \
  --no-reboot

--no-reboot means the snapshots hold only what had already been written to the volumes: buffered data and anything still in memory is left out. Without the flag, EC2 reboots the instance before imaging (the default), which gets everything onto disk at the price of a short outage. For database-heavy instances drop the flag, or stop the database before imaging. A manual sync flushes the filesystem's buffers, but not what the database itself still holds in memory.

Step 3: Enable ENA on the new AMI explicitly. EC2 honors the source instance's ENA attribute, but for older AMIs the attribute may not propagate:

bash
aws ec2 modify-image-attribute \
  --region :region \
  --image-id ami-0newamiid \
  --ena-support

Step 4: Launch a fresh instance from the new AMI on the destination type:

bash
aws ec2 run-instances \
  --region :region \
  --image-id ami-0newamiid \
  --instance-type :new_type \
  --subnet-id subnet-0abc \
  --security-group-ids sg-0abc \
  --key-name my-key \
  --iam-instance-profile Name=my-instance-profile

Step 5: Reattach Elastic IPs, update DNS / load balancer targets, terminate the old instance after verification.

This is the "no-shortcut" path. It costs an AMI creation (a few cents and 5 to 15 minutes), plus the overlap during which both instances run. Worth it for anything where a failed start-instances would cause customer-visible downtime.

Method 4: ASG rolling replace (zero downtime in production)

For production fleets, the right pattern is to push the new instance type into the Launch Template and let the Auto Scaling Group roll instances one at a time. No planned downtime, health-check gating on every batch, and, once you turn it on, automatic rollback if the new type fails its health checks (auto rollback is off by default).

Update the launch template with the new instance type:

bash
aws ec2 create-launch-template-version \
  --region :region \
  --launch-template-id lt-0abc \
  --source-version 1 \
  --launch-template-data '{"InstanceType":":new_type"}'

Point the ASG at the new version:

bash
aws autoscaling update-auto-scaling-group \
  --region :region \
  --auto-scaling-group-name web-prod \
  --launch-template "LaunchTemplateId=lt-0abc,Version=2"

Trigger the rolling replace. The instance-refresh API replaces instances in batches while respecting min-healthy-percentage:

bash
aws autoscaling start-instance-refresh \
  --region :region \
  --auto-scaling-group-name web-prod \
  --preferences '{"MinHealthyPercentage":90,"InstanceWarmup":120}'

MinHealthyPercentage: 90 is the share of the group's desired capacity that has to stay in service and healthy during the rollover. The command does not set MaxHealthyPercentage, so the maximum defaults to 100 (unless the group has an instance maintenance policy that sets another value) and the refresh replaces 10% of capacity at a time, which means the group runs up to 10% short while each batch is replaced. Set both the minimum and maximum healthy percentage to 100 to make it launch each replacement before terminating the old instance. InstanceWarmup is how long the refresh waits after a new instance passes its health checks and enters InService before it moves on to the next batch. For each batch the ASG terminates the old instances and launches replacements on the new type, waits for those to pass health checks and finish their warmup, then moves on, until the whole fleet runs on the new type.

If the new type fails health checks (network missing because ENA isn't loaded, NVMe driver missing), Auto Scaling terminates and replaces the unhealthy instances, keeps retrying for an hour, then fails the refresh and leaves the rest of the group untouched. It does not undo anything by itself, because AutoRollback is disabled by default. Roll back by hand by pointing the ASG at the previous launch template version and starting another refresh, or let the refresh do it: skip the update-auto-scaling-group step, pass the new version as the desired configuration, and enable auto rollback. The ASG has to be on a specific numbered launch template version for this, not $Latest or $Default:

bash
aws autoscaling start-instance-refresh \
  --region :region \
  --auto-scaling-group-name web-prod \
  --desired-configuration '{"LaunchTemplate":{"LaunchTemplateId":"lt-0abc","Version":"2"}}' \
  --preferences '{"MinHealthyPercentage":90,"InstanceWarmup":120,"AutoRollback":true}'

This is the only pattern I run on customer-facing production. For internal tools and batch workers, Method 1 is fine.

Cost angle: vertical scale vs gp3 + smaller box

Before vertically scaling an instance because it's running out of capacity, check what's actually constrained. Three common findings turn a "bigger instance" decision into a cheaper "different EBS" decision:

  • Disk IOPS is the bottleneck, not CPU. A t3.medium on a gp2 volume of less than 1 TB is throttled to ~3 IOPS per GB with a 3,000 IOPS burst. Switching the volume to gp3 gives you 3,000 IOPS / 125 MiB/s baseline plus provisioned IOPS up to 80,000 and throughput up to 2,000 MiB/s, at lower cost than the equivalent gp2 upgrade. Often eliminates the need for a bigger instance.
  • EBS throughput is capped by instance type, not volume. Every instance type has its own aggregate EBS ceiling regardless of how big the volume is. A t3.large has a baseline of 86.88 MB/s and a maximum of 347.50 MB/s; an m5.large has a baseline of 81.25 MB/s and a maximum of 593.75 MB/s. Both sizes can hold the maximum for only 30 minutes at least once every 24 hours before reverting to baseline, so sustained throughput comes from moving up a size: an m5.xlarge has a 143.75 MB/s baseline and an m5.2xlarge 287.50 MB/s. Sometimes the right answer is a bigger instance with the same disk, not a bigger disk on the same instance.
  • Memory pressure looks like CPU pressure. A small instance under memory pressure starts swapping (or OOM-killing); the visible symptom is CPU saturation. Run free -h and check swap usage before assuming you need more vCPU.

The general order: profile first, switch gp2 to gp3 second, vertically scale third.

Stop vs Hibernate vs Terminate

Three operations look similar in the console; only one is right for changing an instance type.

OperationWhat it doesUse for resize?
StopPowers off, releases the underlying host, EBS volumes persist, instance-store volumes wipeYes
HibernateSaves RAM contents to the root EBS volume, then stopsNo: incompatible with modify-instance-attribute for type changes
TerminatePowers off and deletes the instance + (by default) the root EBS volumeNo: this is destructive

Stop is the correct verb for a resize. Hibernate preserves RAM state, which is useful for warm-restart workflows but conflicts with the instance-type change because the saved RAM image is tied to the original instance's CPU and memory shape. Terminate is for "I'm done with this instance forever," not "I want to make it bigger."

Comparison: four ways to change an instance type

ApproachDowntimeRiskWhen to use
Stop + modify + start30 to 90 secondsLow (one instance)Single dev / staging / batch instance
Snapshot AMI + relaunchNone on the original, then DNS cutoverLower (old instance stays up)Xen → Nitro jump, instance-store root, untested AMI
ASG rolling replaceNoneLowest (gated by health checks)Production fleets behind a load balancer
Terraform instance_type change30 to 90 seconds (default)Low if lifecycle configuredInfra-as-code estates; pair with ASG for prod

Terraform note: changing instance_type on an aws_instance resource performs an in-place modification (stop, modify, start), not a replacement. The instance ID stays the same. Confirm by running terraform plan first; the line should read ~ instance_type (modify) not -/+ (replace). If it reads replace, an unrelated attribute is forcing a new resource; look at the diff above to find which one.

Common pitfalls

1. Instance store data loss on stop. Anything on /dev/nvme1n1 or higher (the instance-store volumes on m5d, r5d, c5d, i3, x1, x2) is wiped the moment you stop the instance. EBS root survives. Instance store does not. Back up first.

2. Public IPv4 changes after stop. Unless you have an Elastic IP, the public IPv4 is released on stop and reassigned (from a different pool) on start. DNS records pointing at the old IP break. Either use an Elastic IP for anything where the IP matters, or update DNS as part of the resize procedure.

3. ENA / NVMe missing on the AMI. The instance boots, fails its 2/2 status check, and you spend 20 minutes wondering why. Either install the drivers in the AMI before the resize, or use Method 3 and bake a new AMI explicitly.

4. T-family CPU credits across a stop. T instances accumulate CPU credits while running and burn them during spikes. A stopped T3, T3a, or T4g instance keeps its accrued CPUCreditBalance for seven days, so a quick resize does not throw the credits away. A T2 instance loses all accrued credits the moment it stops, so expect baseline-only performance for a while after a T2 resize. On an unlimited instance, any surplus credits already spent are charged when it stops.

5. Reserved Instance and Savings Plan coverage. Whether a Reserved Instance still applies after the resize depends on its scope. A regional RI for Linux/UNIX on default tenancy, Standard or Convertible, has instance size flexibility: the discount follows any size in the same family, so t3.medium to t3.large stays covered, fully or in part according to the normalization factor. A zonal RI, and any RI for Windows, RHEL, SUSE, or dedicated tenancy, matches one exact instance type, and no RI follows you to a different family (t3 to m5). Convertible RIs can be exchanged; Standard RIs cannot. Savings Plans are more forgiving for resize-heavy fleets: a Compute Savings Plan applies regardless of instance family, size, Region, OS, or tenancy, while an EC2 Instance Savings Plan is tied to one family in one Region and covers every size in it.

6. Dedicated tenancy and dedicated hosts. A shared-tenancy instance cannot be modified into a dedicated-tenancy instance and vice versa. The error message reads "InvalidInstanceAttributeValue" with no further explanation; check tenancy first.

7. Placement group families. Cluster placement groups require 10 Gbps capable instance types. Trying to modify into a type that doesn't qualify (older T family, for example) fails the start. Spread placement groups have laxer rules. Partition placement groups have the same general constraint as cluster.

8. --instance-type JSON quoting on Windows / PowerShell. PowerShell single-quoted strings are verbatim, so '{"Value": "t3.large"}' is the form the AWS CLI guide recommends there too. If the inner double quotes get lost on the way to the CLI (PowerShell handing the argument over under the Windows CommandLineToArgvW rules), keep the single quotes and put a backslash before each inner double quote: '{\"Value\": \"t3.large\"}'. The backslash is not an escape inside a PowerShell double-quoted string (the backtick is), so wrapping the JSON in double quotes with backslashes does not work. Or use the shorthand --instance-type t3.large if your CLI version supports it.

What to do next

FAQ

No. The modify-instance-attribute API requires the instance to be in the stopped state before the instance type can be changed. A running instance returns IncorrectInstanceState.

The closest thing to a zero-downtime resize is the ASG rolling-replace pattern: push the new instance type into the launch template, then run start-instance-refresh. The Auto Scaling Group replaces the old instances one batch at a time with new instances on the new type and waits for health checks between batches. The application stays up (on slightly reduced capacity during each batch, unless you set both healthy percentages to 100), but no individual instance is "resized" in place.

EBS-backed root and data volumes survive a stop-modify-start cycle. The volumes detach from the host during stop and reattach when the instance starts on the new type. File contents, partition tables, and filesystem UUIDs all persist. On Nitro instance types the NVMe device name can change between starts, so mount by UUID or label, not by device name.

Instance-store volumes do not survive. Anything on /dev/nvme1n1 and higher (the local SSDs on m5d, r5d, c5d, i3, and similar families) is wiped permanently the moment the instance stops. Snapshot or rsync that data to EBS or S3 before resizing.

Three commands in order: aws ec2 stop-instances --instance-ids i-0abc, then aws ec2 modify-instance-attribute --instance-id i-0abc --instance-type '{"Value": "t3.large"}', then aws ec2 start-instances --instance-ids i-0abc. Note the JSON wrapper around the type value; this is the documented form and works on every CLI version since 2013.

Use aws ec2 wait instance-stopped and aws ec2 wait instance-running between the steps if you're scripting the resize. The wait commands block until the state transition completes, which avoids a race where modify-instance-attribute fires before the instance has actually stopped.

Yes, but only if the AMI has the ENA network driver and NVMe block-storage driver loaded. Nitro families (C5, M5, R5, T3 and every newer family) use ENA for network and NVMe for EBS attachment, while older Xen families (M3, C3, M4, C4) use the Xen drivers.

If the AMI lacks either driver, the instance boots on the Nitro type but fails its status check (no network, no root volume). The safe path is the snapshot-AMI-and-relaunch flow: install the drivers, bake a new AMI, set the ena-support attribute explicitly with modify-image-attribute, then launch a fresh instance on the Nitro type from the new AMI.

Yes, as long as the destination type meets the AMI's compatibility requirements and the workload fits in the smaller memory footprint. Downsizes from m5.xlarge to m5.large, c5.2xlarge to c5.large, and t3.large to t3.medium all work with the same stop-modify-start procedure.

The constraint that catches people is memory: an instance that has been running for weeks with a 6 GB resident set cannot suddenly fit on a 4 GB instance. The instance starts on the new type, but the workload OOM-kills under load. Check the actual memory usage (not the allocated heap) before downsizing.

Yes, if the instance has only a default AWS-assigned public IPv4. The address is released on stop and reassigned from the regional pool on start; the new address is almost never the same as the old one.

An Elastic IP avoids this. The Elastic IP detaches from the instance during stop and reattaches automatically on start, so the public IPv4 is stable across resize operations. Private IPv4 addresses inside the VPC are always stable. IPv6 addresses, when configured, are also stable across stop-start.

For an EBS-backed instance, the full stop-modify-start sequence completes in 30 to 90 seconds. The stop takes the longest (15 to 60 seconds depending on the OS's shutdown hooks); the modify is instant; the start completes in 10 to 30 seconds.

Status checks (2/2) typically take another 60 to 120 seconds to pass after start. Application-level warmup (JIT compilers, in-memory caches, connection pools) can take longer, which is why production resizes go through an ASG rolling replace with an InstanceWarmup period before the next instance is drained.

Modify (the path described in this post) preserves the instance ID, EBS volume attachments, security groups, IAM role, key pair, tags, user data, and Elastic IP. The instance is the same instance afterward, just on different hardware.

Replace (launch a new instance from an AMI, terminate the old one) produces a new instance ID and requires reattaching anything that's instance-ID-scoped. Replacement is what the snapshot-AMI-and-relaunch and ASG rolling-replace patterns both do. Modify is faster for single instances; replace is required when the destination type is not driver-compatible with the current AMI.

Sources

Authoritative references this article was fact-checked against.

TagsAWSEC2Instance TypesNitroDevOpsCLIAuto ScalingEBS

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Systems and Network Architect · Chief Technology Officer

Systems and network architect and Chief Technology Officer with more than two decades designing, building, and running production software, cloud and network architecture, Linux systems, and the bare metal underneath them, and lately working AI into the stack. A US Army veteran who served in Operation Iraqi Freedom. What I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

Connect to an AWS EC2 instance using plain SSH with a key pair, EC2 Instance Connect, AWS Systems Manager Session Manager, or an EC2 Instance Connect Endpoint for private instances. Default usernames, security group rules, and troubleshooting Permission denied and Connection timed out.

How to SSH into an AWS EC2 Instance

Connect to an EC2 instance four ways: plain SSH with a key pair, EC2 Instance Connect, Session Manager, and EC2 Instance Connect Endpoint. Default usernames, security group rules, and the troubleshooting matrix that fixes Permission denied and Connection timed out.

Download an Instagram Reel or video free with yt-dlp. Public posts can work logged out, but plan on cookies: pass --cookies-from-browser firefox, keep them fresh, and save reels or audio.

How to Download an Instagram Reel or Video with yt-dlp

Download an Instagram Reel or video free from the command line with yt-dlp. A public post can download logged out, but Instagram rate-limits anonymous requests and gates private ones, so plan on cookies: how to pass them, keep them fresh, and grab reels, feed videos, IGTV, or just the audio.