Skip to content

Instantly share code, notes, and snippets.

@mauricios
Created November 14, 2016 20:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricios/4ed107d5e1d7c67379b702c7cc4ac17c to your computer and use it in GitHub Desktop.
Save mauricios/4ed107d5e1d7c67379b702c7cc4ac17c to your computer and use it in GitHub Desktop.
AWS EC2 User Data setting hostname
#cloud-config
apt_upgrade: false
preserve_hostname: true
runcmd:
- hostname "Hostname-`ec2metadata --instance-id`"
- echo "127.0.0.1 Hostname-`ec2metadata --instance-id`" >> /etc/hosts
- echo "Hostname-`ec2metadata --instance-id`" > /etc/hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment