Skip to content

Instantly share code, notes, and snippets.

View YarGnawh's full-sized avatar

Ray Hwang YarGnawh

View GitHub Profile
@YarGnawh
YarGnawh / ec2-hostname.sh
Last active March 2, 2016 21:47
AWS EC2 Ubuntu Update HOSTNAME Using JSON USER_DATA
#!/bin/bash
# Write to /usr/local/ec2/ec2-hostname.sh
# Execute chmod 755 ec2-hostname.sh
# Append /usr/local/ec2/ec2-hostname.sh to /etc/rc.local
# Referenced: http://ternarylabs.com/2010/09/15/automatically-configure-hostname-for-new-ec2-instances/
USER_DATA=`/usr/bin/curl -s http://169.254.169.254/latest/user-data`
IPV4=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/public-ipv4`