Change EC2 Instance Type Using AWS CLI
Tasks
- Change the instance type from - t2.microto- t2.nanofor the- nautilus-ec2instance using- aws-clionly.
- Ensure the - nautilus-ec2instance is in the- runningstate after the change.
Steps
- Get the instance ID and Stop the - nautilus-ec2instance:- 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
- Wait until the instance is stopped: 
aws ec2 wait instance-stopped --instance-ids i-0a089a6cf430546c4- Change the instance type to - t2.nano:
aws ec2 modify-instance-attribute --instance-id i-0a089a6cf430546c4 --instance-type "{\"Value\": \"t2.nano\"}"- Start the - nautilus-ec2instance:
aws ec2 start-instances --instance-ids i-0a089a6cf430546c4- Ensure the instance is in the - runningstate:- aws ec2 wait instance-running --instance-ids i-0a089a6cf430546c4
- Check the instance type now. 
aws ec2 describe-instances --instance-ids i-0a089a6cf430546c4 --query "Reservations[*].Instances[*].InstanceType" --output text
#aws #cloudcomputing #happylearning