genevieve / leftovers

Go cli & library for cleaning up orphaned IAAS resources.
Apache License 2.0
149 stars 22 forks source link

Feature/regex matching #105

Open notrepo05 opened 3 years ago

notrepo05 commented 3 years ago

We would like to be able to match using regex. I'm opening this as a draft since we plan to continue working / redesigning before trying to get our changes merged in :).

Example use case:

nrohn-a01 nr $ BBL_IAAS=aws ./leftovers -f "pull-1408.*security" --aws-secret-access-key=*** --aws-access-key-id=***  --aws-region=*** --dry-run --filter-as-regex
[EC2 Security Group: nat_security_group (Name:pull-1408-nat-security-group, Environment:pull-1408, Application:Cloud Foundry)]
[EC2 Security Group: ops_manager_security_group (Environment:pull-1408, Application:Cloud Foundry, Name:pull-1408-ops-manager-security-group)]
[EC2 Security Group: web_lb_security_group (Name:pull-1408-lb-security-group, Environment:pull-1408, Application:Cloud Foundry)]
[EC2 Security Group: rds_security_group (Application:Cloud Foundry, Name:pull-1408-rds-security-group, Environment:pull-1408)]
[EC2 Security Group: tcp_lb_security_group (Environment:pull-1408, Application:Cloud Foundry, Name:pull-1408-tcp-lb-security-group)]
[EC2 Security Group: ssh_lb_security_group (Name:pull-1408-ssh-lb-security-group, Environment:pull-1408, Application:Cloud Foundry)]
...

This PR also reorders some AWS resource deletion by their type, and adds waits to a couple resources so we don't fail improperly (especially important for RDS, which takes ~10 minutes to delete)

Thanks!

cc @ciriarte

notrepo05 commented 3 years ago

TODOs

notrepo05 commented 3 years ago

Hi @genevieve, if we wanted to get this merged upstream I assume we'll need to reintroduce vendoring and add more test coverage? Would you also want us to refactor the regex filter flag? We can also maintain our own fork if that's preferable. Thank you!!

genevieve commented 3 years ago

Hey Nick! Yes, if you wouldnt mind reintroducing vendoring and adding more test coverage, we can merge these changes!

notrepo05 commented 3 years ago

Thanks! I'll try to get it ready to be merged in a couple weeks.

notrepo05 commented 3 years ago

Thank you for the review @rowanjacobs. I still need to get around to getting this ready for merge. I'm trying to find time