Skip to content

fix: support wildcard filtering in EC2 filters#837

Merged
hectorvent merged 3 commits into
floci-io:mainfrom
kapoorp99:fix/ec2-wildcard-filtering
May 14, 2026
Merged

fix: support wildcard filtering in EC2 filters#837
hectorvent merged 3 commits into
floci-io:mainfrom
kapoorp99:fix/ec2-wildcard-filtering

Conversation

@kapoorp99
Copy link
Copy Markdown
Contributor

Add wildcard pattern matching support to EC2 filter values to match AWS behavior.

Changes:

  • Added wildcardToRegex() method to convert AWS wildcard patterns (* and ?) to Java regex
  • Added matchesValue() method for pattern-based value matching
  • Updated all filter matching logic to use wildcard patterns instead of exact string matching
  • Supports wildcard filtering for all filter types: tag filters, tag-key, tag-value, and resource-specific filters
  • Applies to all EC2 resources: VPCs, Subnets, Security Groups, Instances, Internet Gateways, Route Tables, Volumes

Added comprehensive integration tests:

  • describeVpcsWithWildcardTagFilter: Tests asterisk wildcard patterns
  • describeVpcsWithWildcardQuestionMark: Tests question mark wildcard patterns

All 69 EC2 integration tests pass. Backward compatible with exact string matching.

Fixes #830

Add wildcard pattern matching support to EC2 filter values to match AWS behavior.

Changes:
- Added wildcardToRegex() method to convert AWS wildcard patterns (* and ?) to Java regex
- Added matchesValue() method for pattern-based value matching
- Updated all filter matching logic to use wildcard patterns instead of exact string matching
- Supports wildcard filtering for all filter types: tag filters, tag-key, tag-value, and resource-specific filters
- Applies to all EC2 resources: VPCs, Subnets, Security Groups, Instances, Internet Gateways, Route Tables, Volumes

Added comprehensive integration tests:
- describeVpcsWithWildcardTagFilter: Tests asterisk wildcard patterns
- describeVpcsWithWildcardQuestionMark: Tests question mark wildcard patterns

All 69 EC2 integration tests pass. Backward compatible with exact string matching.

Fixes floci-io#830
Copilot AI review requested due to automatic review settings May 14, 2026 04:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds AWS-style wildcard matching for EC2 filter values, addressing wildcard tag filtering behavior for DescribeVpcs and applying the shared filter matching path across EC2 resources.

Changes:

  • Adds wildcard-to-regex matching for EC2 filter values.
  • Replaces exact contains checks with pattern-based matching across supported EC2 filters.
  • Adds integration coverage for VPC tag filters using * and ? wildcards.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java Implements wildcard-aware EC2 filter matching.
src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java Adds integration tests for wildcard VPC tag filtering.
Comments suppressed due to low confidence (1)

src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java:1226

  • EC2 filter wildcards can be escaped with a backslash to match literal * and ?, but this conversion treats \ as a literal regex backslash and still expands the following wildcard. That makes filters such as Value=foo\*bar match foo\anythingbar instead of a tag value of foo*bar, which diverges from AWS wildcard filtering. Consume the escaped character and quote it as a literal before applying wildcard expansion.
        }

Comment thread src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Prakhar Kapoor <59886854+kapoorp99@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@hectorvent hectorvent added bug Something isn't working ec2 labels May 14, 2026
Copy link
Copy Markdown
Collaborator

@hectorvent hectorvent left a comment

Choose a reason for hiding this comment

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

Thanks @kapoorp99,

This is a great addition to Floci.

@hectorvent hectorvent merged commit e4666df into floci-io:main May 14, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ec2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Filtering with wild card values not possible

3 participants