Skip to content

Instantly share code, notes, and snippets.

@dblencowe
Created January 9, 2017 10:33
Show Gist options
  • Save dblencowe/a9d51ee3adc4b4d33dabed2a92a5ea6f to your computer and use it in GitHub Desktop.
Save dblencowe/a9d51ee3adc4b4d33dabed2a92a5ea6f to your computer and use it in GitHub Desktop.
Get a public IP and write it to /etc/hosts
#!/usr/bin/env bash
IP=`aws ec2 describe-instances --profile lfc-staging --filters "Name=tag:machinetype,Values=web" | grep -m 1 PrivateIpAddress | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'`
sed -i -e "s/.*lfc-staging$/$IP lfc-staging/g" /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment