Last active
October 6, 2015 13:52
-
-
Save seventhskye/e2788a00a54ae6649e06 to your computer and use it in GitHub Desktop.
Userdata snippet to add register and deregister commands to an ubuntu instance in aws
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
"cat << EOF > /etc/init.d/register_with_elb\n", | |
"#!/bin/bash\n", | |
"aws elb register-instances-with-load-balancer --load-balancer-name ", | |
{ | |
"Ref": "LoadBalancerName" | |
}, | |
" --instances $(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id) --region ", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
"\n", | |
"EOF\n", | |
"chmod +x /etc/init.d/register_with_elb && update-rc.d register_with_elb start 19 2 3 4 5 . \n", | |
"cat << EOF > /etc/init.d/deregister_from_elb\n", | |
"#!/bin/bash\n", | |
"aws elb deregister-instances-from-load-balancer --load-balancer-name ", | |
{ | |
"Ref": "LoadBalancerName" | |
}, | |
" --instances $(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id) --region ", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
"\n", | |
"EOF\n", | |
"chmod +x /etc/init.d/deregister_from_elb && update-rc.d deregister_from_elb start 19 0 6 . \n", | |
"\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment