Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tchia04
Copy link
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
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