Created
June 3, 2020 14:51
-
-
Save AstroTom/455dcae0db5ef83ca9a391d58cf61106 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# | |
# resize an ec2 from and GPU g4dn.xlarge to t3.medium | |
# | |
AWS_INSTANCE_ID=i-0d286d48c371f57b1 | |
TYPE=t3.medium | |
echo This will stop your instance $AWS_INSTANCE_ID to type $TYPE | |
# find name | |
echo Name tag is: | |
echo -e -n "\t" | |
aws ec2 describe-tags --filters "Name=resource-id,Values=$AWS_INSTANCE_ID" "Name=key,Values=Name" --output text|cut -f5 | |
echo type is: | |
echo -e -n "\t" | |
aws ec2 describe-instances --instance-ids $AWS_INSTANCE_ID --query 'Reservations[*].Instances[*].InstanceType' --output text | |
read -p "This will stop the instance. (Press Enter to continue)" | |
echo Stopping your instance. | |
aws ec2 stop-instances --instance-ids $AWS_INSTANCE_ID | |
#echo type is: | |
#echo -e -n "\t" | |
#aws ec2 describe-instances --instance-ids $AWS_INSTANCE_ID --query 'Reservations[*].Instances[*].InstanceType' --output text | |
aws ec2 modify-instance-attribute --instance-id $AWS_INSTANCE_ID --instance-type '{"Value": "'$TYPE'"}' | |
echo New type is: | |
echo -e -n "\t" | |
aws ec2 describe-instances --instance-ids $AWS_INSTANCE_ID --query 'Reservations[*].Instances[*].InstanceType' --output text | |
read -p "Do you want to start the instance? (Press Enter to continue, ^C to exit)" | |
echo "Restarting your instance with new size..." | |
aws ec2 start-instances --instance-ids $AWS_INSTANCE_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment