I am trying to clean up my AWS configuration and I want to know if particular subnets are actually used/have any resources in them.
I'm aware you can filter a list of a particular resource type (e.g. EC2 instances) by subnet id, through the AWS web interface, but I am not yet aware of all of the different resource types that may be used - so I am concerned I may miss something.
I have tried inspecting the subnet via the AWS CLI, but I can't see anything that clearly differentiates subnets that are in use and those that are not:
aws ec2 describe-subnets
This question deals with enumerating all IP addresses within a particular subnet's CIDR block, but it doesn't reveal how to show only active IP addresses (which I could presumably use to find the attached AWS resources and confirm a subnet is indeed in use).
This seems like it would be a common task, but I can find no AWS documentation or SO posts on how to do this. Perhaps there is something flawed in my approach.
aws ec2 describe-instances
. It supports--filter
forsubnet-id
. docs.aws.amazon.com/cli/latest/reference/ec2/… – Suter