如何在AWS CLI中列出所有VPC依赖项?


21

我想通过CLI删除VPC。但是得到一个错误:

A client error (DependencyViolation) occurred when calling the DeleteVpc operation: The vpc 'vpc-xxx' has dependencies and cannot be deleted.

如何列出阻止我删除此VPC的所有依赖项?


我也有同样的问题。您找到解决方案了吗?
大卫·拉比诺维兹

Answers:


7

这就是使用AWS CLI最终对我有用的东西。我知道除子网外还有其他依赖项,但这是一个开始:

jcomeau@aspire:~$ aws ec2 describe-subnets
{
    "Subnets": [
        {
            "VpcId": "vpc-9a5c2bfe", 
            "CidrBlock": "10.0.0.0/25", 
            "MapPublicIpOnLaunch": false, 
            "DefaultForAz": false, 
            "State": "available", 
            "AvailabilityZone": "us-east-1c", 
            "SubnetId": "subnet-10923666", 
            "AvailableIpAddressCount": 123
        }
    ]
}
jcomeau@aspire:~$ aws ec2 delete-subnet --subnet-id=subnet-10923666
jcomeau@aspire:~$ aws ec2 delete-vpc --vpc-id=vpc-9a5c2bfe
jcomeau@aspire:~$

好的,所以这并不适用于我的全部。这是另一个:

jcomeau@aspire:~$ aws ec2 describe-internet-gateways
{
    "InternetGateways": [
        {
            "Tags": [], 
            "InternetGatewayId": "igw-37e81153", 
            "Attachments": [
                {
                    "State": "available", 
                    "VpcId": "vpc-e2087c86"
                }
            ]
        }
    ]
}
jcomeau@aspire:~$ aws ec2 detach-internet-gateway --internet-gateway-id=igw-37e81153 --vpc-id=vpc-e2087c86
jcomeau@aspire:~$ aws ec2 delete-internet-gateway --internet-gateway-id=igw-37e81153
jcomeau@aspire:~$ aws ec2 delete-vpc --vpc-id=vpc-e2087c86
jcomeau@aspire:~$

4

我相信没有CLI函数可以返回导致DependencyViolation错误的原因,因此您有两种选择:

  1. 登录到AWS管理控制台,然后搜索指向VPC的任何组件,它可以是安全组,子网,路由器表,EC2等。
  2. 与AWS支持团队联系,并检查他们是否可以确定您的原因。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.