Skip to main content

Command Palette

Search for a command to run...

Modify EC2 Instance Type via AWS CLI

Change EC2 Instance Type Using AWS CLI Commands

Published
1 min read
Modify EC2 Instance Type via AWS CLI
A

Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.

Tasks

  • Change the instance type from t2.micro to t2.nano for the nautilus-ec2 instance using aws-cli only.

  • Ensure the nautilus-ec2 instance is in the running state after the change.

Steps

  1. Get the instance ID and Stop the nautilus-ec2 instance:

     aws ec2 describe-instances --filters "Name=tag:Name,Values=nautilus-ec2" --query "Reservations[*].Instances[*].InstanceId" --output text
    

    • i-0a089a6cf430546c4
aws ec2 stop-instances --instance-ids i-0a089a6cf430546c4

  1. Wait until the instance is stopped:
aws ec2 wait instance-stopped --instance-ids i-0a089a6cf430546c4
  1. Change the instance type to t2.nano:
aws ec2 modify-instance-attribute --instance-id i-0a089a6cf430546c4 --instance-type "{\"Value\": \"t2.nano\"}"
  1. Start the nautilus-ec2 instance:
aws ec2 start-instances --instance-ids i-0a089a6cf430546c4
  1. Ensure the instance is in the running state:

     aws ec2 wait instance-running --instance-ids i-0a089a6cf430546c4
    
  2. Check the instance type now.

aws ec2 describe-instances --instance-ids i-0a089a6cf430546c4 --query "Reservations[*].Instances[*].InstanceType" --output text

#aws #cloudcomputing #happylearning

Cloud Platforms

Part 13 of 48

This series covers cloud platforms (AWS, Azure, GCP, OCI), including certifications, labs, issues, solutions, and billing. We'll also explore on-premises solutions and hybrid cloud environments.

Up next

Launch EC2 Instance via AWS CLI

How to Launch an EC2 Instance Using AWS CLI