Skip to content

Instantly share code, notes, and snippets.

@iAnomaly
Last active January 8, 2019 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iAnomaly/1f878f5f2fe1591963338f5087914104 to your computer and use it in GitHub Desktop.
Save iAnomaly/1f878f5f2fe1591963338f5087914104 to your computer and use it in GitHub Desktop.
Shell one-liners
# AWS NAT Gateways per AZ
aws ec2 describe-nat-gateways | jq -r '.NatGateways[]|select(.State=="available").SubnetId' | xargs aws ec2 describe-subnets --subnet-id | jq -r '.Subnets[].AvailabilityZone' | sort | uniq -c
# SSH command across all EC2 instance with name tag using bastion/jump-box and dumping 1024 DNS queries to EC2 DNS
aws --output text ec2 describe-instances --query 'Reservations[].Instances[?Tags[?Key==`Name`&&contains(Value,`my-name`)]].PrivateDnsName' | xargs -I % -n 1 -P $(sysctl -n hw.ncpu) ssh -i ~/.ssh/key.pem -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -J ubuntu@bastion.name admin@% "uname -n; sudo /usr/sbin/tcpdump -i eth0 -lnc 1024 dst 172.29.0.2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment