Is there any way to find unused VPCs in an AWS account?
I mean the VPCs that don't have any EC2 instances, RDS and other services associated with it.
One way is to just search with VPC ID in running instances, RDS and for other services to find out whether it is in use or not. Is there any other way or AWS CLI to find unused VPCs?
By default you can create up to 5 VPCs. You can ask for additional VPCs using the VPC Request Limit Increase form. You can now check the status of each of your VPN Connections from the command line or from the VPC tab of the AWS Management Console.
VPC sharing is only available within the same AWS Organization. Sharing of default VPCs/subnets is not possible. Participants can't launch resources using security groups that are owned by other participants or the owner.
There are many resources that be included in a VPC, such as:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With