Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brontolinux
Last active August 14, 2020 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brontolinux/284bd8d7c54f0f9d60f40cb8c7209022 to your computer and use it in GitHub Desktop.
Save brontolinux/284bd8d7c54f0f9d60f40cb8c7209022 to your computer and use it in GitHub Desktop.
Translates an AWS instance ID to the private DNS name
function id2dns() {
if [ -z "$1" ]; then
echo "Usage: id2ip instanceID [instanceID...]"
else
aws ec2 describe-instances --instance-ids $* --output text --query 'Reservations[].Instances[].PrivateDnsName'
fi
}
@brontolinux
Copy link
Author

brontolinux commented Aug 13, 2020

Requires:

  • the AWS CLI
  • the jq command
  • valid AWS credentials set in the shell

Update 2020-08-14: jq not needed any more, using the --output text and --query is just as fine, and doesn't need an additional software :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment