Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify dateOlderThan documentation to provide full syntax #756

Closed
jamesgeddes opened this issue Mar 9, 2022 · 11 comments
Closed

Clarify dateOlderThan documentation to provide full syntax #756

jamesgeddes opened this issue Mar 9, 2022 · 11 comments

Comments

@jamesgeddes
Copy link
Contributor

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

@jamesgeddes
Copy link
Contributor Author

jamesgeddes commented Mar 10, 2022

Also posted at SO

@svenwltr
Copy link
Member

svenwltr commented Mar 11, 2022

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

@nhemchand
Copy link

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?

@rayyin-ps
Copy link

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

@jamesgeddes
Copy link
Contributor Author

That's handy!

@nhemchand
Copy link

nhemchand commented Mar 29, 2022

  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 )

@jamesgeddes jamesgeddes changed the title Nuke dateOlderThan now.AddDate(0, 0, -7) Clarify dateOlderThan documentation to provide full syntax Apr 7, 2022
@jamesgeddes
Copy link
Contributor Author

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

I have updated the ticket title accordinly

@svenwltr
Copy link
Member

svenwltr commented Apr 7, 2022

Hello. Please take a look at this answer: #767 (comment)

@jamesgeddes
Copy link
Contributor Author

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
Copy link
Contributor Author

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?

@svenwltr
Copy link
Member

svenwltr commented Apr 8, 2022

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

This is discussed here: #480

Equally, is it too late to change it now?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants