09 / 09

Can you change the instance type of a running EC2 instance?

No, you cannot change the instance type of a running EC2 instance. You must first stop the instance, then change the instance type, and finally start the instance again. This process causes downtime and changes the public IP (unless using an Elastic IP).

Resizing an EC2 instance (changing its type) is a common operational task when a workload grows or shrinks. However, it requires the instance to be in a stopped state. The process is straightforward but does involve a brief downtime window. For zero-downtime resizing in production, you typically launch a new instance of the desired type and swap it behind a load balancer.

Steps to Change the Instance Type
  1. 1
    1. Stop the instance — aws ec2 stop-instances --instance-ids i-xxxx (NOT terminate)
  2. 2
    1. Wait for the instance to reach the stopped state
  3. 3
    1. Change the instance type — aws ec2 modify-instance-attribute --instance-id i-xxxx --instance-type t3.large
  4. 4
    1. Start the instance — aws ec2 start-instances --instance-ids i-xxxx
  5. 5
    1. Verify the new type — aws ec2 describe-instances and check InstanceType field
Changing Instance Type via AWS CLI
Important Considerations When Changing Instance Type
  1. 1

    Downtime is required — the instance must be stopped, which interrupts all running services

  2. 2

    Public IP changes — unless you have an Elastic IP attached, the public IPv4 address will change after the restart

  3. 3

    Instance store data is LOST — if the current instance has instance store volumes, all data on them is wiped on stop

  4. 4

    EBS volumes are preserved — all EBS-backed volumes remain intact and reattach after the type change

  5. 5

    Virtualization compatibility — some older instance types use HVM while newer ones use Nitro. Most modern instance types are compatible.

  6. 6

    CPU architecture compatibility — you cannot switch from an x86 instance type (e.g., m5) to an ARM/Graviton instance type (e.g., m6g) without reinstalling or recompiling your application binaries

  7. 7

    License implications — Windows instances with BYOL (Bring Your Own License) may have licensing tied to physical host characteristics

Zero-Downtime Resize Strategy (Production Recommended)
  1. 1

    Launch a new EC2 instance of the desired type using the same AMI

  2. 2

    Configure the new instance (install app, set environment variables)

  3. 3

    Register the new instance with the Application Load Balancer (ALB) target group

  4. 4

    Gradually shift traffic using weighted target groups or connection draining

  5. 5

    Deregister and terminate the old instance once all connections have drained

  6. 6

    This approach is fully automated with Auto Scaling Groups and Launch Templates