-
Notifications
You must be signed in to change notification settings - Fork 22
C7N Filter Refactor: Extract Mixins: Create CELFilter subclass
When using CEL filters, there will be no longer be unique Filter
subclasses embedded in a policy. All unique processing for the various specialized filters need to be refactored.
Instead of specialized Filter
subclasses, a new CELFilter
class will be used. This must have all of the other filter subclass mixins available in it.
For two examples of the consequences of this, consider type: image-age
and type: metrics
filters.
-
image-age
. The description of an AWS EC2 instance has an image identifier, but no details on the image. The C7NImageAge
subclass of theFilter
class queries image information for an EC2 instance to locate the image creation date. The processing gathers additional information not directly part of the resource description. -
metrics
. A number of AWS resources have CloudWatch metrics. The C7NMetrics
subclass of theFilter
class queries the metrics statistics for all available resources, then applies the filter rule to all of the responses.
In both cases, a subclass of the Filter
class defines the additional processing. In the case of ImageAge
, it's a clearly-separated mixin. In the case of MetricsFilter
, there isn't as clear a distinction between gathering data and applying the operator to the results.
When using CEL filters, there will not be a number unique Filter
subclasses. Instead there will be one CELFilter
subclass of Filter
.
The processing must be refactored into this CELFilter
object. Perhaps as plug-in strategy objects, or perhaps as mixin class definitions.
For resource types with Images, an InstanceImageBase
mixin must be part of the CELFilter
class.
For resource types that can provide CloudWatch Statistics, a new MetricsAccess
mixin must be part of the CELFilter
class.
Initially, it appears that Config, Health, KMS, Revisions, and VPC's all require refactoring of the mixins that provide raw data to the filter.
Refactor the Filter
class hierarchy to extract the "Data Gathering" features into easily segregated mixin classes.
Define a new CELFilter
class that includes the mixins extracted from the legacy Filter
subclasses.