There are many resources that be included in a VPC, such as:
- Amazon EC2 instances
- Amazon RDS instances
- Amazon Redshift instances
- Amazon Elasticache instances
- Elastic Load Balancers
- Elastic Network Interfaces
- and so on!
Rather than trying to iterate through each of these services, you could iterate through the Elastic Network Interfaces (ENIs), since everything connects to a VPC via an ENI.
Here's a command you could run using the AWS Command-Line Interface (CLI) that shows ENIs attached to a given VPC:
aws ec2 describe-network-interfaces --filters 'Name=vpc-id,Values=vpc-abcd1234' --query 'NetworkInterfaces[*].NetworkInterfaceId'
If no ENIs are returned, then you'd probably call it an unused VPC.