aws-nuke icon indicating copy to clipboard operation
aws-nuke copied to clipboard

Clarify dateOlderThan documentation to provide full syntax

Open jamesgeddes opened this issue 2 years ago • 11 comments

How do you nuke resources that are more than 7 days old, rather than older than a fixed date?

jamesgeddes avatar Mar 09 '22 11:03 jamesgeddes

Also posted at SO

jamesgeddes avatar Mar 10 '22 09:03 jamesgeddes

I think you have to specify the date in hours: 168h.

svenwltr avatar Mar 11 '22 08:03 svenwltr

Can you provide a syntax for the cleaning up EC2 instances that are 30 days or older. Does it work with other EC2 conditions in place as well?

nhemchand avatar Mar 21 '22 19:03 nhemchand

@jamesgeddes According to the docs, a value of "-7d" should work.

rayyin-ps avatar Mar 24 '22 16:03 rayyin-ps

That's handy!

jamesgeddes avatar Mar 24 '22 17:03 jamesgeddes

  1. This code snippet does not seem to be working. Im still able to delete ec2 instance of 60days old. ######################
EC2Instance:
        - property: dateOlderThan
          value: "time.Now().AddDate(0, 0, -90d)"

######################

  1. Can similar logic as above used for other 375 resources as well? nuke resource-types | wc -l ( 375 resources )

nhemchand avatar Mar 29 '22 17:03 nhemchand

Same here, I'm still getting 0 filtered regardless of what I put in.

I have updated the ticket title accordinly

jamesgeddes avatar Apr 07 '22 13:04 jamesgeddes

Hello. Please take a look at this answer: https://github.com/rebuy-de/aws-nuke/issues/767#issuecomment-1090185334

svenwltr avatar Apr 07 '22 13:04 svenwltr

Riiiiight! Makes sense!

It would certainly be helpful if the readme could explicitly clarify this, particularly as I am apparently not the only person to be confused 😂 Thank you in advance

jamesgeddes avatar Apr 07 '22 13:04 jamesgeddes

It would also be helpful to clarify the logic that dateOlderThan is using.

For example, I now have the config of,

accounts:
  xxxxxxxxxxxx:
    filters: 
      EC2Instance:
        - property: LaunchTime
          type: dateOlderThan
          value: "100h"
      S3Bucket:
        - property: Name
          value: "foo"

As I understand it, if an object matches the filter, it is skipped, so here, I would expect the following to be saved

  • all buckets named "foo"
  • all EC2 instances that have LaunchTime of older than 100 hours.

What actually happens is that the following are saved,

  • all buckets named "foo"
  • all EC2 instances that have LaunchTime of younger than 100 hours.

Conveniently, I wanted to save new instances anyway, however, is this behaviour counterintuitive? Equally, is it too late to change it now?

jamesgeddes avatar Apr 07 '22 15:04 jamesgeddes

Conveniently, I wanted to save new instances anyway, however, is this behaviour counterintuitive?

This is discussed here: https://github.com/rebuy-de/aws-nuke/pull/480

Equally, is it too late to change it now?

Yes, this would break the filters of everyone using it.

svenwltr avatar Apr 08 '22 08:04 svenwltr