Last active
January 26, 2018 16:53
-
-
Save esroberts/3d8fc0ea809a5b073784f3551661b6cb to your computer and use it in GitHub Desktop.
cli functions and aliases to make finding DNS targets in Route 53 easier
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
aws_find_dns_records() { | |
# args: <Zone ID> <pattern> where pattern is a string to search against DNS record names | |
# returns: table of A and CNAME records that match | |
zone="$1"; val="$2"; shift; | |
aws route53 list-resource-record-sets --hosted-zone-id "$zone" --query "ResourceRecordSets[?(Type==\`A\` || Type==\`CNAME\`) && contains(Name, '$val')].[Name, AliasTarget.DNSName, ResourceRecords[0].Value, Type]" --output table; | |
} | |
aws_find_zone_ids() { | |
# args: <pattern> string pattern to match against zone name | |
# returns: table of DNS Hosted Zone Ids and other details | |
val="$1"; shift; | |
aws route53 list-hosted-zones --query "HostedZones[?contains(Name, '$val')][Name, Id, Config.PrivateZone, Config.Comment]" --output table | |
} | |
aws_find_elb() { | |
# args: <fqdn of elb> fully qualified load balancer name. Should not include 'dualstack.' prefix | |
# returns: data about the elb | |
val="$1"; shift; | |
aws elb describe-load-balancers --query "LoadBalancerDescriptions[?DNSName=='$val']" --output text | |
} | |
aws_find_instances() { | |
# args: <id1> <id2> ... space-separated list of instance ids | |
# returns: data about instances | |
aws ec2 describe-instances --instance-ids "$@" --output text | |
} | |
alias adns='aws_find_dns_records' | |
alias azone='aws_find_zone_ids' | |
alias aelb='aws_find_elb' | |
alias aec2='aws_find_instances' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment