Skip to content

Instantly share code, notes, and snippets.

@ziwon
Last active April 3, 2024 08:55
Show Gist options
  • Save ziwon/9479f6113e37843d10717d6762f17eea to your computer and use it in GitHub Desktop.
Save ziwon/9479f6113e37843d10717d6762f17eea to your computer and use it in GitHub Desktop.
Get the number of pods per running instance type
#!/bin/bash
export AWS_PROFILE=default
aws ec2 describe-instances --region ap-northeast-2 \
| jq '.Reservations[] | .Instances[] | {type: .InstanceType, tag: .Tags[] | select(.Key=="Name").Value}' \
| jq -s '.' \
| jq 'sort_by(.type) | group_by(.type)[] | {
type: .[0].type,
name: map(.tag)} | "\( .type ): \( .name | join(", ") )"' | tr -d \" | awk -F '' '{if (NF > 110) {print substr($0, 0, 110)".."} else print $0}' \
| xargs -I {} bash -c 'T="{}"; curl -s -L https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/files/eni-max-pods.txt | grep ${T%:*}; printf "> ${T#*:}\n";';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment