How to change the EC2 instance type

Changing the instance type of an Amazon EC2 instance involves a few steps, and it can be done either through the AWS Management Console or via the Command Line Interface (CLI). Before doing so, please note that certain instance types may only be applicable depending on your Virtual Private Cloud (VPC) and underlying hardware, so ensure the new type meets your requirements.

💡
This works for EBS volumes only. If you change the instance type, the data on EBS volume will not be affected.

Considerations for compatible instance types

Consider the following when changing the instance type of an existing instance:

  • You must stop your Amazon EBS-backed instance before you can change its instance type. Ensure that you plan for downtime while your instance is stopped. Stopping the instance and changing its instance type might take a few minutes, and restarting your instance might take a variable amount of time depending on your application's startup scripts. For more information, see Stop and start your instance.

  • When you stop and start an instance, we move the instance to new hardware. If your instance has a public IPv4 address, we release the address and give your instance a new public IPv4 address. If you require a public IPv4 address that does not change, use an Elastic IP address.

  • You can't change the instance type if hibernation is enabled for the instance.

  • You can't change the instance type of a Spot Instance.

  • If your instance is in an Auto Scaling group, the Amazon EC2 Auto Scaling service marks the stopped instance as unhealthy, and may terminate it and launch a replacement instance. To prevent this, you can suspend the scaling processes for the group while you're changing the instance type. For more information, see Suspending and resuming a process for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

  • When you change the instance type of an instance with NVMe instance store volumes, the updated instance might have additional instance store volumes, because all NVMe instance store volumes are available even if they are not specified in the AMI or instance block device mapping. Otherwise, the updated instance has the same number of instance store volumes that you specified when you launched the original instance.

  • The maximum number of Amazon EBS volumes that you can attach to an instance depends on the instance type and instance size. You can't change to an instance type or instance size that does not support the number of volumes that are already attached to your instance. For more information, see Instance volume limits.

Launch EC2 instance:

To launch a test EC2 instance use the following guide:

How to launch a single EC2 instance via AWS CLI

The hands-on labs below show how to change the EC2 instance type from t2.micro to t2.small via Management Console and AWS CLI.

Hands-On Lab: Change EC2 Instance Type via AWS Management Console:

  1. Stop the Instance: Before you can change the instance type, you must stop the instance. Navigate to the EC2 dashboard, select the instance you want to modify, and click the "Instance State" dropdown menu. Then select "Stop instance."

  2. Wait for the Instance to Stop: The status of the instance should change to "stopped." It may take a few minutes.

  3. Change the Instance Type: With the instance selected, click on the "Actions" dropdown, then "Instance Settings," and choose "Change instance type."

  4. Select New Instance Type: From the dialog box, choose the new instance type you want, then click "Apply."

  5. Start the Instance: Go back to the "Instance State" dropdown and select "Start instance."

Hands-On Lab: Change EC2 Instance Type via AWS CLI:

  1. Stop the Instance:

     aws ec2 stop-instances --instance-ids i-1234567890abcdef0
    

    To get the instance ID use the following command:

      aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value | [0], State.Name]' --output table
    

    To check the Instance state use the following command:

     aws ec2 describe-instances --instance-ids i-1234567890abcdef0 --query 'Reservations[*].Instances[*].State.Name' --output text
    
  2. Change the Instance Type:

     aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --instance-type t2.small
    
  3. Start the Instance:

     aws ec2 start-instances --instance-ids i-1234567890abcdef0
    

Applicability:

  • Instance Type Compatibility: You can change to any instance type that is compatible with the configuration of the AMI and other specifications that you used to launch the instance.

  • EBS-backed Instances: The above process will work for instances using EBS volumes. Instance-store backed instances can't have their types changed without relaunching.

  • VPC Requirements: Make sure that the selected instance type is available in your VPC and region.

Always refer to the latest AWS documentation and consider your specific requirements and constraints when changing an instance type.

References

  1. Change the instance type