#!/bin/bash aws ec2 describe-security-groups | jq -cr '.SecurityGroups[].GroupId' | while read s; do echo -n "$s: " aws ec2 describe-network-interfaces --filters Name=group-id,Values=$s | jq -cr '[.NetworkInterfaces[].NetworkInterfaceId] | length' done