这就是使用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:~$