yamlaws-nuke

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


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?


Solution

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