Behnaz shows you how to
troubleshoot dependency errors
when deleting a VPC

Behnaz_troubleshoot-dependency-error-delete-vpc-1

I received a dependency error when I tried to delete my Amazon Virtual Private Cloud (Amazon VPC). How do I delete my Amazon VPC? 

Before you can delete your Amazon VPC, you must delete its dependent resources. Otherwise, you might receive a dependency error.

If you delete your Amazon VPC using the Amazon VPC console, all its components--such as subnets, security groups, network ACLs, route tables, internet gateways, VPC peering connections, and DHCP options--are also deleted. If you use the AWS Command Line Interface (AWS CLI) to delete the Amazon VPC, you must terminate all instances, delete all subnets, delete custom security groups and custom route tables, and detach any internet gateway in the Amazon VPC before you can delete the Amazon VPC.

To delete an Amazon VPC, first terminate your instances in the Amazon VPC. If the Amazon VPC has running Amazon EC2 instances, you will receive the following error: "VPC contains one or more instances, and cannot be deleted until those instances have been terminated."

If the Amazon VPC has network interfaces for other AWS services, such as Amazon Relational Database Service (Amazon RDS), Amazon WorkSpaces, or Amazon ElastiCache, you will receive one of the following errors:

  • Network vpc-xxxxxxxx has some mapped public address(es). Please unmap those public address(es) before detaching the gateway.
  • Network interface 'eni-xxxxxxxx' is currently in use.

To resolve these errors, determine which service is dependent by following these steps:

  1. Open the Amazon EC2 console.
  2. Select the region that the Amazon VPC is in.
  3. In the navigation pane, under Network Interfaces, search for the VPC ID that you want to delete.
  4. Choose the elastic network interface, choose the Details view, and check the Description to see which resource the interface is attached to.
  5. Delete the associated resource.
    Note: If it is a Primary network interface, it will be deleted when you will delete the instance.
  6. Delete the Amazon VPC.

You must also delete any security group references from the default security group. If the default security group of the Amazon VPC references other security groups from the Amazon VPC, you will receive the following error: "Resource sg-xxxxxxxx has a dependent object". For more information about deleting security groups, see Deleting a Security Group.


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2017-12-18