Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

dateOlderThan for EC2 instances and other resource #640

Closed
nmiculinic opened this issue May 18, 2021 · 2 comments · Fixed by #670
Closed

dateOlderThan for EC2 instances and other resource #640

nmiculinic opened this issue May 18, 2021 · 2 comments · Fixed by #670

Comments

@nmiculinic
Copy link

Maybe I've misread the docs....though I want to kill all EC2 instances older than 2h for example. (among other resources).

Can I achieve this with this tool, or is it not in the feature set.

@rbroemeling
Copy link
Contributor

@nmiculinic I was trying to do something very similar today and also couldn't figure out how to do it. After spelunking in the code, I found that for EC2 instances, the launchTime metadata is not populated into the properties for that resource -- which means that at the moment, there doesn't appear to be any easy way to nuke EC2 instances that are >= X hours old.

Ref:

func (i *EC2Instance) Properties() types.Properties {

This looks pretty useful and easy to add, so hopefully it'll be fixed relatively easily. If I have a few moments, I might open a PR to fix it myself.

@rbroemeling
Copy link
Contributor

I implemented the necessary properties to underly this behaviour and have submitted them in #670. After that PR has been merged, this will be possible with a filter statement like this:

      EC2Instance:
      - property: "LaunchTime"
        type: dateOlderThan
        value: "2h"

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

Successfully merging a pull request may close this issue.

2 participants