Last active
August 29, 2015 14:08
-
-
Save brb/1c0823e49113b4478e8f to your computer and use it in GitHub Desktop.
poor man's Elastic IP
This file contains 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 | |
# Update /etc/hosts with public non-elastic IPs of EC2 instances. | |
# Assumes that a name is set for each instance and there is only one value inside tags section. | |
PREFIX="aws_" | |
FILTER=".Reservations[].Instances[] | | |
select(.PublicIpAddress != null) | | |
.PublicIpAddress + \" $PREFIX\" + .Tags[].Value" | |
sudo sed -i "/$PREFIX/d" /etc/hosts | |
aws ec2 describe-instances | jq -r "$FILTER" | sudo tee -a /etc/hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment