Created
December 15, 2016 21:24
-
-
Save nicolaihald/0dd53ac22ad9b4d0c1c04c51e2c20106 to your computer and use it in GitHub Desktop.
AWS - Userdata script to setup a basic web page with instance id and tag instance
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
| #!/bin/bash | |
| 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>" > /var/www/html/index.html | |
| aws ec2 create-tags --resources "$instanceId" --tags Key=Name,Value="WEB-ASG-NODE-$instanceId" --region "$region" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment