aws/aws-cli

add --all-dependencies option to ec2 delete-vpc

meonkeys opened this issue ยท 68 comments

Feature request

support aws ec2 delete-vpc --all-dependencies --vpc-id vpc-deadbeef

Details

The AWS web console will delete a VPC along with all its dependencies. The aws cli tool says (when trying to delete a VPC with any dependencies): A client error (DependencyViolation) occurred when calling the DeleteVpc operation: The vpc 'vpc-deadbeef' has dependencies and cannot be deleted.

  1. Subnets
  2. Security Groups
  3. Network ACLs
  4. VPN Attachments
  5. Internet Gateways
  6. Route Tables
  7. Network Interfaces
  8. VPC Peering Connections

Maybe also add --vpn-connection.

Something like this might be handy, but it requires more magic smoke than I'm really comfortable with. I would suggest making this request on the EC2 forums. If they add it to their API, we'll be able to pick it up immediately.

I am in need for this feature, also.
๐Ÿ‘ from me

bzz commented

@JordonPhillips is not it all about just listing dependencies and removing them one by one, or is it something more than that?

+1 Is there any progress with this feature?

+1 frome me

A definite +1

+1 I have bunches of vpc's to be deleted.

+1

+1

๐Ÿ‘

+1

+1000

+1

+1

+10000000

+1

+1

+1

+1

+1

Azure has a concept of resource-group, anything in that gets deleted. Something similar could also be useful.

+1

I understand there is significant desire for this feature to be added to the CLI. Currently we have no plans to implement this functionality in the CLI. The feature is a moving target, requiring frequent updates as EC2 adds functionality. There is also the issue with the ambiguity of what resources should be deleted, especially ones tangentially related to the VPC, such as snapshots. In the end, it makes more sense to do this server-side, especially so that all of the SDKs and Tools can benefit from this feature.

Please continue to share feedback and input on the linked EC2 forum thread.

Trevorrowe.. This might be a moving target, but there is no ambiguity. The --all-dependencies should handle removing every dependency that would otherwise prevent the vpc from being deleted. If something is tangentially linked, the --all-dependencies should unlink it from the VPC.

Clicking hundreds of VPCs one by one on the GUI is a garbage way of getting VPC's closed en-masse. I'd much rather feed my shell script, and work on something less tedious.

If the GUI interface gets a mass vpc-close option, I'd be down for that too.

Do cusotmers care if the VPC (and it's dependencies) get deleted via the client or server side code?

What customers do care about is a way to fully delete the VPC (and deps) via an action from the AWS CLI or when there is a Cloudformation delete. There are many asymmetries and exceptions all across AWS that reveal a trail of teams not working together on more complex issues.

Why can't we expose an API to the (AWS Console) server side function to delete a VPC and use that API in the CLI and CloudFormation? If organizational boundaries are getting in the way of providing users with fixes to critical bugs and gaps, why push that burden onto the customers. Customers posting in another project's forum thread is a pretty weak method to change cross org priorities.

The current situation where we can build a stack automatically but cannot not reliably tear it down automatically is getting tired. How many wasted hours of time do customers spend to manually work work around this? How many aws resources are underutilized because they are bound to half torn down VPC's?

Did anyone write script to delete all VPC in aws including the related resources?

+99999999999999999

If anyone wants I can provide a nodejs script I utilize for doing just this when I delete a eks cluster with eksctl since it can't clean the vpc for some reason because of dependencies. :)

for doing just this when I delete a eks cluster with eksctl since it can't clean the vpc for some reason because of dependencies. :)

can yo share it?

+99999999999999999

If anyone wants I can provide a nodejs script I utilize for doing just this when I delete a eks cluster with eksctl since it can't clean the vpc for some reason because of dependencies. :)

HAHAHA boss, I am trying the same thing !!

Of course Amazon drags their feed in giving a cleanup tool
why should they since its a revenue generator to leave all these dangling unwanted resources running ... this has been an issue for MANY years ... since the beginning I dare say ... so sad

as a big fat band-aid it would be reasonable if the vps delete command ( along with all similar aws cli commands ) had a verbose mode which showed offending still attached resources which are preventing the delete - D'oh

This might help. It's in ruby, but it shows the ordering you need to delete VPC's. You will have to have tagged your resources to use this out of the box, but the order seem's to be key for a few of you. Resource order is a pain across the major Cloud's. We suffer daily. Hope this helps. If you have VPN gateways and peering you will just have to delete those before the rest of the resources in the script.

Opens the musty tome

https://gist.github.com/gregohardy/ef026eef3beddae49eb05ea0fe5993e0

Of course Amazon drags their feed in giving a cleanup tool
why should they since its a revenue generator to leave all these dangling unwanted resources running ... this has been an issue for MANY years

So true unfortunately

is there any way i can get what are the dependency attached to particular resource so before deleting main resource i will delete dependency first.
for example i want to delete network interface but i am getting operation not allowd error.
can any one suggest me what the things i need to delete before deleting network interface.

i stuck in my task i want to delete all unused resource from my aws endvironment

Seriously need this - can spend an entire day easily running around in circles trying to remove a VPC - its the most annoying nonsense.

This is a basic feature everyone needs. It took me days to implement a VPC resource crawler to remove everything.

+100000000000

+1

It's my script to delete a VPC with all dependencies
https://github.com/lianghong/delete_vpc

Similarly, I've used https://github.com/toddm92/vpc-delete in the past.

@lianghong thanks you legend that worked like a charm!!

@lianghong u charming devil

@lianghong THANK YOU !

Any update on this? Still really needed.

+1

+1

I wrote a tool to delete a VPC and all of its dependencies: https://github.com/isovalent/aws-delete-vpc

The AWS cli functionality should reflect that which is available in the AWS console. This issue should be reopened

voycey commented

Awful that this doesnt exist still

We need this functionality to handle IaC!

dmenig commented

+1

bump