ekristen / azure-nuke

Remove all resources from an Azure Tenant and it's Subscriptions.
https://ekristen.github.io/azure-nuke/
MIT License
32 stars 8 forks source link

Delete resources older than X days #81

Open FlorentClarret opened 1 month ago

FlorentClarret commented 1 month ago

Hello and thanks for this useful tool!

My goal is to drop resources that are older than X days, following this part of the docs.

I tested with VirtualMachine and it does not work. I'm not familiar with this repo but I think that's because TimeCreated is not mapped here: https://github.com/ekristen/azure-nuke/blob/d952ce21e255b073fdf89b755c67b63764610642/resources/virtual-machine.go#L79-L88

I had a quick look at the azure SDK and I'm not even sure they expose this field, I only saw it for the Disk resource.

Would it be possible to add this feature? I'd be happy to help if needed!

ekristen commented 1 month ago

Correct. It would need to be added to here https://github.com/ekristen/azure-nuke/blob/d952ce21e255b073fdf89b755c67b63764610642/resources/virtual-machine.go#L29-L35 then mapped in your link. I'll take a look. Azure is pretty junky to work with, especially with their sdks. :facepalm:

ekristen commented 1 month ago

@FlorentClarret glad you like the tool. Looks like the current SDK doesn't expose it but there's a newer SDK I need to move to, perhaps it supports that field. I'll take a look and see what I can do. For now I'll leave it open.

ekristen commented 2 weeks ago

@FlorentClarret I figured out how to get CreationDate on VirtualMachine, I'll get it in an upcoming release.