google / cloud-forensics-utils

Python library to carry out DFIR analysis on the Cloud
Apache License 2.0
452 stars 89 forks source link

instance.Delete() fails if no VPC is attached #462

Closed cugu closed 9 months ago

cugu commented 1 year ago

instance.Delete() fails if no VPC is attached.

Failing example code snippet:

instance = account.ec2.GetInstanceById(instance_id)
instance.Delete()

A key error is thrown at: https://github.com/google/cloud-forensics-utils/blob/a71b13c3a7108e4d37879007617203c5e34170ff/libcloudforensics/providers/aws/internal/ec2.py#L250

Fryyyyy commented 1 year ago

I am finding it hard to repro this as its not currently possible to create an EC2 instance without a VPC, as far as I can tell

Fryyyyy commented 1 year ago

However it doesn't appear as though VPC is required for the delete procedure, so I don't see why we can't just set a default for this value if it doesn't exist

cugu commented 1 year ago

Not sure how this occurred, but had this happen in an investigation. Thanks for the fix!