Skip to content

Instantly share code, notes, and snippets.

@isindir
Last active November 1, 2018 09:31
Show Gist options
  • Save isindir/f814afcabe5ba8993c1cf3ffa28c05fe to your computer and use it in GitHub Desktop.
Save isindir/f814afcabe5ba8993c1cf3ffa28c05fe to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function ls-ec2() {
if [[ $1 != "" ]]; then
region=$1
else
region='eu-west-1'
fi
aws ec2 describe-instances --output json --region $region \
| jq -r '
[
"ImageId",
"InstanceId",
"InstanceType",
"AvailabilityZone",
"State",
"PrivateIpAddress",
"NetworkGroupName"
],
[
"=======",
"==========",
"============",
"================",
"=====",
"================",
"================"
],
(.Reservations[].Instances[] |
[
.ImageId,
.InstanceId,
.InstanceType,
.Placement.AvailabilityZone,
.State.Name,
.PrivateIpAddress,
.NetworkInterfaces[].Groups[].GroupName
]
) | @tsv' \
| column -t
# .SubnetId,
}
function ls-elb() {
if [[ $1 != "" ]]; then
region=$1
else
region='eu-west-1'
fi
aws elb describe-load-balancers --output json --region $region \
| jq -r '
[
"DNSName",
"Target",
"LoadBalancerPorts"
],
[
"=======",
"======",
"================="
],
(.LoadBalancerDescriptions[] |
[
.DNSName,
.HealthCheck.Target,
.ListenerDescriptions[].Listener.LoadBalancerPort
]
) | @tsv' \
| column -t
}
function ls-zones() {
aws route53 list-hosted-zones --output json \
| jq -r '
[
"ZoneId",
"Name",
"RecordCount"
],
[
"=======",
"====",
"============"
],
(.HostedZones[] | [.Id, .Name, .ResourceRecordSetCount]) | @tsv
' | column -t
}
function ls-rec() {
aws route53 list-resource-record-sets --hosted-zone-id $1 --output json \
| jq -r '
[
"Name",
"Type",
"TTL"
],
[
"====",
"====",
"==="
],
(.ResourceRecordSets[] | [.Name, .Type, .TTL]) | @tsv
' | column -t
}
# ------------------------
# Say I'm done
# ------------------------
# $- here is used to determine if it interactive shell or not
# tty -s could be used instead as well
if [[ $- == *i* ]];then
echo "$( basename $0 ) loaded"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment