Skip to content

Instantly share code, notes, and snippets.

@iAnomaly
Last active July 9, 2024 17:43
Show Gist options
  • 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

GitLab stop environments stuck in "stopping"

http "https://gitlab.com/api/v4/projects/40328438/environments?states=stopping" "Authorization: Bearer $GITLAB_ACCESS_TOKEN" | jq '.[].id' | xargs -n1 -I{} http post "https://gitlab.com/api/v4/projects/40328438/environments/{}/stop?force=true" "Authorization: Bearer $GITLAB_ACCESS_TOKEN"

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 [email protected] 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