====== Virtual Private Cloud (VPC) ======
===== Show unused Security Groups =====
#!/bin/bash
#Get all security groups and check against network interfaces thety are allocated to.
echo "" > security_groups.txt
for SG in
$(aws ec2 describe-security-groups --profile nonprod_admin | jq --raw-output '.[][] | [.GroupId, .GroupName, .Description ] | @csv')
do
echo $SG
#echo $SG | tee security_groups.txt | cut -f1 -d | aws ec2 describe-network-interfaces --filters Name=group-id,Values=${SG} --profile nonprod_admin
done
# clean up temporary mess
rm security_groups.txt
===== Get subnets in VPC =====
$ aws ec2 describe-subnets | jq .Subnets.[].SubnetId
"subnet-1234abcdab7899876"
"subnet-12341bcd207959876"