Skip to content

Added get-dns-from-instance-id and get-instance-id-from-dns to do the…#14

Open
tchia04 wants to merge 1 commit intoawslabs:masterfrom
tchia04:instance_id_and_dns_conversion
Open

Added get-dns-from-instance-id and get-instance-id-from-dns to do the…#14
tchia04 wants to merge 1 commit intoawslabs:masterfrom
tchia04:instance_id_and_dns_conversion

Conversation

@tchia04
Copy link
Copy Markdown
Contributor

@tchia04 tchia04 commented Jan 10, 2017

… conversion without using console or complicated cli

Sample Usage:

aws get-dns-from-instance-id i-aabbccddeeffgghh

aws get-instance-id-from-dns foo.bar.example.com

… conversion without using console or complicated cli
@kyleknap
Copy link
Copy Markdown
Contributor

Thanks for the PR! One question I have is if you possibly simplify both to:

get-dns-from-instance-id =
  !f() {
    aws ec2 describe-instances \
    --instance-ids "${1}" \
    --query 'Reservations[*].Instances[*][PublicDnsName]' --output text
  }; f

get-instance-id-from-dns =
  !f() {
    aws ec2 describe-instances \
    --filters "Name=dns-name,Values=${1}" \
    --query 'Reservations[*].Instances[*][InstanceId]' --output text
  }; f

That way you do not have to pipe the output to cut. As a bonus, if you do not want to run this in a separate subprocess, you could simplify one of the aliases to:

get-dns-from-instance-id =
    ec2 describe-instances \
    --query 'Reservations[*].Instances[*][PublicDnsName]' --output text \
    --instance-ids

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants