Closed smarunich closed 5 years ago
Wouldn't doubt it's a useful feature; here some thoughts:
I am not sure yet, if I want to add a filter just for creation dates or a generic filter for any available attribute of a resource. Here are some attributes of an aws_instance
as an example:
{
AmiLaunchIndex: 0,
Architecture: "x86_64",
BlockDeviceMappings: [{
DeviceName: "/dev/sda1",
Ebs: {
AttachTime: 2017-08-10 16:09:16 +0000 UTC,
DeleteOnTermination: true,
Status: "attached",
VolumeId: "vol-09644310d1093e962"
}
}],
ClientToken: "",
EbsOptimized: false,
Hypervisor: "xen",
IamInstanceProfile: {
Arn: "arn:aws:iam::433795108307:instance-profile/foo",
Id: "SFDFLDISDFDFIFDF"
},
ImageId: "ami-6327c61b",
InstanceId: "i-094962b5a5e51416e",
InstanceType: "m3.medium",
LaunchTime: 2017-08-10 16:09:15 +0000 UTC,
Monitoring: {
State: "enabled"
},
NetworkInterfaces: [{
Attachment: {
AttachTime: 2017-08-10 16:09:15 +0000 UTC,
AttachmentId: "eni-attach-4795ba34",
DeleteOnTermination: true,
DeviceIndex: 0,
Status: "attached"
},
...
I think your primary use case is really "I am allowing my users to create EC2 instances, potentially via a IAM role that restricts them to a single VPC, and I want to make sure that they don't forget and leave them running". I think your secondary use case is "Some orchestration system spewed grime all over my account and I want it all dead."
As such, yeah, probably arbitrary field searching is fine, you just want to include in the docs a few super-common use cases.
I think that doing timestamp greater than / less than is critically important. Within a range is less important but still useful.
Kube selectors are probably the most likely prior art, although they don't support time math. But I suspect that sets are handy as well as booleans (because I might want to say all servers over 24 hours old unless they have a magic tag).
If you had to spend the absolute minimum of time on this, I'd say implement just the timestamp math in a way that is compatible with kube selectors and only bother with compute instances.
Ok, I started working on a filter that might look like this in the yaml. This way intervals are supported too :) Filter works on any resource that has a created info.
aws_instance:
created:
before: 2018-06-14 12:15
after: 2018-09-15
Working on it: https://github.com/cloudetc/awsweeper/pull/24
Btw, the feature is implemented and merged to the master branch. I just haven't done a release yet as I am working on automating the build pipeline to do integration tests and releasing. New release coming soon.
Feature is added in https://github.com/cloudetc/awsweeper/releases/tag/v0.3.0. Let me know if we can close this issue.
Thank you @jckuester , it is indeed helpful and works as expected!
Hi There,
Awesome project, it would be fantastic if Creation Date filter would exist for all type of objects.
Cheers, smarunich