How do you terminate resources that are older than x days using aws-nuke?

696 Views Asked by At

I am using aws-nuke to prune resources in our sandbox account. I would like to only delete resources that are more than 7 days old.

I have tried the following

accounts:
  ************:
    filters:
      EC2Instance:
      - property: dateOlderThan
        value: "time.Now().AddDate(0, 0, -7)"

I have also tried subtracting one day.

accounts:
  ************:
    filters:
      EC2Instance:
      - property: dateOlderThan
        value: "time.Now().AddDate(0, 0, -1)"

I have also tried subtracting 27 years.

accounts:
  ************:
    filters:
      EC2Instance:
      - property: dateOlderThan
        value: "time.Now().AddDate(0, 0, -10000)"

All return the same results,

Scan complete: x total, x nukeable, 0 filtered.

This suggests that the date calculation is being ignored.

How do I give it the current date minus 7 days?

1

There are 1 best solutions below

0
On BEST ANSWER

According to aws-nuke#756, you can either,

  • specify the date in hours: 168h
  • specify -7d