Skip to content

Instantly share code, notes, and snippets.

Last active August 14, 2020 08:48
What would you like to do?
Translates an AWS instance ID to the private DNS name
function id2dns() {
if [ -z "$1" ]; then
echo "Usage: id2ip instanceID [instanceID...]"
aws ec2 describe-instances --instance-ids $* --output text --query 'Reservations[].Instances[].PrivateDnsName'
Copy link

brontolinux commented Aug 13, 2020


  • 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