Last active
May 6, 2022 06:29
-
-
Save mehdi89/cba5ac72b6aac00c180b325ffcd4b04e to your computer and use it in GitHub Desktop.
Change AWS instance type from terminal (stop -> change instance type -> start)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "instance id: $1" | |
echo "instance type: $2" | |
#2>&1 > /dev/null to suppress the cli output | |
echo "stopping instance" | |
aws ec2 stop-instances --instance-ids $1 2>&1 > /dev/null | |
echo "waiting for instance to stop" | |
aws ec2 wait instance-stopped --instance-ids $1 | |
echo "changing instance type" | |
aws ec2 modify-instance-attribute --instance-id $1 --instance-type $2 | |
echo "starting instance" | |
aws ec2 start-instances --instance-ids $1 2>&1 > /dev/null | |
echo "waiting for instance to start" | |
aws ec2 wait instance-running --instance-ids $1 | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment