Skip to content

Instantly share code, notes, and snippets.

View bjethwan's full-sized avatar

Bipin Jethwani bjethwan

  • Temenos
  • India
View GitHub Profile
@bjethwan
bjethwan / gist:7645746a89a8c0182b5f13dcb62e6972
Last active June 3, 2017 12:11 — forked from mikepfeiffer/gist:7c949e2d04c9e51ef204fb9a7f3d2978
Userdata script to setup a basic web page with instance id and tag instance
#!/bin/bash
yum update -y
yum install httpd -y
/sbin/chkconfig --levels 235 httpd on
service httpd start
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id)
region=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
echo "<h1>$instanceId</h1><br/><h3>This is to test AWS ELB with Auto Scaling Group</h3><h4> Bipin Jethwani</h4>" > /var/www/html/index.html
aws ec2 create-tags --resources "$instanceId" --tags Key=Name,Value="PROD-$instanceId" --region "$region"