WIth awscli, Other route tables can be deleted but the main route table cannot be deleted. there are no explicit and implicit subnet associations to the main route table and no routes except the local route.
When trying the same in console, gives the same dependency error but by deleting the VPC itself, it gets deleted.
so tried Deleting the vpc itself through awscli but it gives the dependency error (main route table) .
Are you sure you deleted all of the dependencies of the vpc? The console will prompt you and ask for confirmation to delete all the sub-resources. The CLI is making an api call which requires you to delete those sub-resources manually, and responds with the error if you have not.
am using ansible to create the vpc with two subnets. By default, the main route table is created when creating the vpc. The two subnets has two route tables associated with it. The main route table has only the local route and no external associations with any subnets.
So, (termination is also done in ansible) while terminating/deleting the vpc, first all resources that depend on this vpc has been deleted, then two subnets and two route tables except the main route table has been deleted.
I had a doubt that it may be a bug in ansible that it cant delete the main route table. So, installed awscli and configured it.
Deleting the main route table with aws cli also gives the dependency violation error even though main route table has no dependency. tried deleting the main route table through console, gives me the same error.
So, now the created VPC which now has only the main route table has dependency can be deleted from web-console. But it cannot be deleted from awscli provided the vpc-id which gives the dependecy violation error. I agree that main route table is the dependency here.
Deletion of main route table even though it doesn't have any dependency gives a dependency error both in web-console and awscli.
the VPC which contain only the main route tableas dependency can be deleted from console but cannot be deleted from awscli.
Sorry if I sound a bit pedantic here, but route tables and subnets aren't the only dependencies. There are also Internet Gateways that need to be detached before you can delete the VPC. The console will do that for you, but with the CLI you have to make the call explicitly. There are a few other resources that can be attached to your VPC that will need to be dealt with before it can be removed.
I'm not sure what else could be the culprit. I've created several VPCs and was able to delete them via the CLI just fine once I'd gone through the process of deleting / detaching everything. Given that it's a service-returned error I have a hard time believing it has anything to do with your development environment.
I completely understand how the cli works and for your information I have also detached the internet gateway. Anyways i will try it again and let you know by monday. hold up this issue until that. Thanks for the quick response.
Awesome, I'll give it another look today too
The culprit was the empty security groups. Now, after deleting the security groups, deletion of vpc can be made. Thanks for the patience.
Glad everything worked out!
+1 I am more curious about local internet gateway. is it unique for route table or local for complete VPC?
I have Main Route table in my account where i am trying to disassociate the associations have for it.
It is giving me this below error:
Botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the DisassociateRouteTable operation: cannot disassociate the main route table association rtbassoc-0def944
How do i need to disassociate the subnets from the Main Routetable using aws cli or boto3 commands.
Most helpful comment
The culprit was the empty security groups. Now, after deleting the security groups, deletion of vpc can be made. Thanks for the patience.