Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support Global Filters #25

Closed
ekristen opened this issue Jan 31, 2024 · 2 comments · Fixed by #37
Closed

Feature: Support Global Filters #25

ekristen opened this issue Jan 31, 2024 · 2 comments · Fixed by #37

Comments

@ekristen
Copy link
Owner

ekristen commented Jan 31, 2024

It would be nice to allow for a global filter to be define that is merged into all filters.

Global would be overwritten by local if there's a conflict.

References

@YuriGal
Copy link

YuriGal commented Feb 15, 2024

Wow that was fast, cool!

This filter will be generic, not just for tags, correct? E.g. if we want to filter any resource with "controltower" or "sso" in their names something like this

filters:
  *:
    - property: 'Name'
      type: 'regex'
      value: '(?i:sso|controltower)'

would work?

@ekristen
Copy link
Owner Author

I've been working on my own fork of aws-nuke for a while and rewriting it for a couple months to make additions like this easier to do. It just so happens I've been working on this specific thing for a little while now trying to find the most intuitive way to implement.

Correct, the syntax I'm working on is the following

filters:
  __global__:
    - property: Name
      type: regex
      value: '(?i:sso|controltower)'

  TestResource:
    - property: tag:testing
      value: test

would result in

filters:
  TestResource:
    - property: Name
      type: regex
      value: '(?i:sso|controltower)'
    - property: tag:testing
      value: test

The filters get appended not a true merge because it's a list, so the global will be added to the front of the filters for the resource, then any specific Resource Filters will get appended to the list. The filters are AND together, so if any of them match, it's filtered.

Side Note: I'm also working on Filter Groups. This will allow you to add a group property to the filter definition. Groups will be OR'd, while filters in the group are AND'd. If group is omitted it's just in the default group and all AND'd together. This would allow for some more complex filtering to take place.

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

Successfully merging a pull request may close this issue.

2 participants