aws-nuke
aws-nuke copied to clipboard
Clarify dateOlderThan documentation to provide full syntax
How do you nuke resources that are more than 7 days old, rather than older than a fixed date?
Also posted at SO
I think you have to specify the date in hours: 168h
.
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?
@jamesgeddes According to the docs, a value of "-7d" should work.
That's handy!
- 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)"
######################
- Can similar logic as above used for other 375 resources as well? nuke resource-types | wc -l ( 375 resources )
Same here, I'm still getting 0 filtered
regardless of what I put in.
I have updated the ticket title accordinly
Hello. Please take a look at this answer: https://github.com/rebuy-de/aws-nuke/issues/767#issuecomment-1090185334
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
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?
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.