Skip to content

Instantly share code, notes, and snippets.

@ypandit
Created September 28, 2012 22:20
Show Gist options
  • Save ypandit/3802361 to your computer and use it in GitHub Desktop.
Save ypandit/3802361 to your computer and use it in GitHub Desktop.
Start an EC2 instance and associate it with an EIP
#! /bin/sh
INSTANCE_ID=''
ELASTIC_IP=''
if [[ `ec2-describe-instances` =~ 'running' ]]; then
echo "AWS instance is already running !"
exit 2
else
ec2start $INSTANCE_ID
sleep 10
fi
done="false"
while [ "$done" != "true" ]
do
if [[ `ec2-describe-instances` =~ 'running' ]]; then
done="true"
echo "AWS instance is running !"
fi
done
ec2-associate-address -i $INSTANCE_ID $ELASTIC_IP
echo "Successfully associated the elastic IP to your instance on AWS !"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment