Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ "$#" -ne 2 ]; then
- echo "Illegal number of parameters! Pass the new instance type and instance id..."
- else
- type=$1
- instance=$2
- aws ec2 stop-instances --instance-ids $instance
- while [ "`aws ec2 describe-instances --instance-ids $instance --output text --query 'Reservations[*].Instances[*].State.Name'`" != "stopped" ]
- do
- echo "Instance is stopping..."
- sleep 1
- done
- echo -e "Instance is stopped \n Changing instance type..."
- aws ec2 modify-instance-attribute --instance-id $instance --instance-type "{\"Value\": \"$type\"}"
- sleep 4
- echo "Start the instance..."
- aws ec2 start-instances --instance-ids $instance
- while [ "`aws ec2 describe-instances --instance-ids $instance --output text --query 'Reservations[*].Instances[*].State.Name'`" != "running" ]
- do
- echo "Instance is starting..."
- sleep 1
- done
- echo "Instance is started..."
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement