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

Skip if tag value is empty or set to true #823

Merged
merged 5 commits into from
Dec 31, 2024

Conversation

wakeful
Copy link
Contributor

@wakeful wakeful commented Dec 23, 2024

Description

Fixes #822, change the exclude by tag behaviour to allow matching by an empty tag value.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.
  • Attention Grunts - if this PR adds support for a new resource, ensure the nuke_sandbox and nuke_phxdevops jobs in .circleci/config.yml have been updated with appropriate exclusions (either directly in the job or via the .circleci/nuke_config.yml file) to prevent nuking IAM roles, groups, resources, etc that are important for the test accounts.

Release Notes (draft)

change the exclude by tag behaviour to allow matching by an empty tag value, fix #822.

Migration Guide

n/a

Copy link
Contributor

@james03160927 james03160927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest changing the existing behavior slightly: if the exclusion tag has no value, we should assume the tag itself indicates that the resource should be excluded. If a value is present, we should check whether it is set to "true."

@wakeful
Copy link
Contributor Author

wakeful commented Dec 25, 2024

I suggest changing the existing behavior slightly: if the exclusion tag has no value, we should assume the tag itself indicates that the resource should be excluded. If a value is present, we should check whether it is set to "true."

Agreed, this simplifies the whole logic quite a lot.

@wakeful wakeful changed the title Skip if tag exist Skip if tag value is empty or set to true Dec 25, 2024
@wakeful wakeful force-pushed the skip-if-tag-exist branch 2 times, most recently from 42de8aa to d224bcd Compare December 25, 2024 22:08
@james03160927
Copy link
Contributor

#822 (comment) - To accommodate this, we could introduce a TagValue property within the FilterRule. The TagValue could default to true, be set to a specific value being targeted, or use *, indicating that it can match any value.

How does this sound?

@wakeful
Copy link
Contributor Author

wakeful commented Dec 27, 2024

#822 (comment) - To accommodate this, we could introduce a TagValue property within the FilterRule. The TagValue could default to true, be set to a specific value being targeted, or use *, indicating that it can match any value.

How does this sound?

I added tag_value to the configuration as a regular expression, primarily because there is already a matches(name string, regexps []Expression) bool function.

The original request should now be easy to address using this configuration. cc: @ErezWeiss

s3:
  exclude:
    tag: Component
    tag_value: .*

@ErezWeiss
Copy link

ErezWeiss commented Dec 30, 2024

@james03160927
@wakeful
@arsci
@denis256

it seems amazing.
Can we proceed?

Copy link
Contributor

@james03160927 james03160927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Passed all the tests.

@james03160927 james03160927 merged commit 9b42f5e into gruntwork-io:master Dec 31, 2024
2 checks passed
@ErezWeiss
Copy link

ErezWeiss commented Dec 31, 2024

@james03160927 thank you.
Can you guys build a version for it?

@wakeful

@wakeful wakeful deleted the skip-if-tag-exist branch December 31, 2024 10:40
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 this pull request may close these issues.

Feature Request: Exclude Resources by Tag Existence
3 participants