Skip to content

feat(elbv2): regex support for listener conditions#36384

Open
azatoth wants to merge 3 commits intoaws:mainfrom
azatoth:regex-conditions
Open

feat(elbv2): regex support for listener conditions#36384
azatoth wants to merge 3 commits intoaws:mainfrom
azatoth:regex-conditions

Conversation

@azatoth
Copy link
Copy Markdown
Contributor

@azatoth azatoth commented Dec 14, 2025

Issue #36363

Closes #36363

Reason for this change

AWS elbv2 now (since when?) supports regex values for host headers, http headers, and path patterns.

Description of changes

Add regex-based condition methods for ALB listener rules:

  • hostHeadersRegex() for host header pattern matching
  • httpHeaderRegex() for HTTP header pattern matching
  • pathPatternsRegex() for URL path pattern matching

These methods use the regexValues CloudFormation property instead of values, allowing for more flexible pattern matching using regular expressions.

Also add comprehensive validation for all listener condition types:

  • Maximum length validation (128 chars for most values, 40 for header names)
  • Non-empty value validation where required
  • Pattern validation for HTTP request methods
  • Maximum count validation (5 items for path patterns, same as before; unknown which number is correct because some pages are saying 3, some are saying 5 and the rest have no idea...)

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Includes unit tests and integration tests for all new functionality.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Dec 14, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team December 14, 2025 19:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 14, 2025

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results48 ran48 passed
TestResult
No test annotations available

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 14, 2025

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates48 ran48 passed
TestResult
No test annotations available

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 14, 2025
@azatoth azatoth force-pushed the regex-conditions branch 4 times, most recently from 921f40d to a8b48a7 Compare January 6, 2026 16:11
@azatoth
Copy link
Copy Markdown
Contributor Author

azatoth commented Jan 6, 2026

@pahud I've problem figuring out how to resolve the Security Guardian failure, not sure what to do. Any help would be appreciated.

@pahud
Copy link
Copy Markdown
Contributor

pahud commented Jan 6, 2026

@pahud I've problem figuring out how to resolve the Security Guardian failure, not sure what to do. Any help would be appreciated.

Hi

You don't need to deal with the security guardian issues for now. Just make sure the CodeBulid CI passes, which at this moment is failing.

https://github.com/aws/aws-cdk/actions/runs/20754299612/job/59591898496?pr=36384

As long as the CodeBuild CI passes, this PR will be queued for review and more inputs will be provided from the maintainers.

Thank you.

@azatoth
Copy link
Copy Markdown
Contributor Author

azatoth commented Jan 6, 2026

@pahud I've problem figuring out how to resolve the Security Guardian failure, not sure what to do. Any help would be appreciated.

Hi

You don't need to deal with the security guardian issues for now. Just make sure the CodeBulid CI passes, which at this moment is failing.

https://github.com/aws/aws-cdk/actions/runs/20754299612/job/59591898496?pr=36384

As long as the CodeBuild CI passes, this PR will be queued for review and more inputs will be provided from the maintainers.

Thank you.

Ah, I thought it was blocking review from the maintainers as it was the only test that failed then; I've have to look into if any of my changes to fix the security guarding issue has caused the error you pointed out; copilot's "explain error" doesn't really point me in any direction I've been poking around in.

@azatoth
Copy link
Copy Markdown
Contributor Author

azatoth commented Jan 6, 2026

@pahud the error seems to be unrelated to my PR:

@aws-cdk-testing/framework-integ:   CHANGED    aws-lambda-nodejs/test/integ.latest 57.754s
@aws-cdk-testing/framework-integ:       Resources
@aws-cdk-testing/framework-integ:       [~] AWS::Lambda::Function latestFE0D80B6
@aws-cdk-testing/framework-integ:        └─ [~] Code
@aws-cdk-testing/framework-integ:            └─ [~] .S3Key:
@aws-cdk-testing/framework-integ:                ├─ [-] 2729d9b4af60cbbbe3182f0002dec1747647eedd8de3761325aa38f7ddf73f24.zip
@aws-cdk-testing/framework-integ:                └─ [+] 069f8376d0e4e8d1eb295d84e1d084c6b79c239097010bc64a3874e37e4a38e6.zip
@aws-cdk-testing/framework-integ:       
@aws-cdk-testing/framework-integ:       
@aws-cdk-testing/framework-integ: Snapshot Results: 
@aws-cdk-testing/framework-integ: Tests:    1 failed, 1333 total
@aws-cdk-testing/framework-integ: Failed: /codebuild/output/src3908876137/src/actions-runner/_work/aws-cdk/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.latest.js
@aws-cdk-testing/framework-integ: Error: Some tests failed!

@pahud
Copy link
Copy Markdown
Contributor

pahud commented Jan 6, 2026

@pahud the error seems to be unrelated to my PR:

@aws-cdk-testing/framework-integ:   CHANGED    aws-lambda-nodejs/test/integ.latest 57.754s
@aws-cdk-testing/framework-integ:       Resources
@aws-cdk-testing/framework-integ:       [~] AWS::Lambda::Function latestFE0D80B6
@aws-cdk-testing/framework-integ:        └─ [~] Code
@aws-cdk-testing/framework-integ:            └─ [~] .S3Key:
@aws-cdk-testing/framework-integ:                ├─ [-] 2729d9b4af60cbbbe3182f0002dec1747647eedd8de3761325aa38f7ddf73f24.zip
@aws-cdk-testing/framework-integ:                └─ [+] 069f8376d0e4e8d1eb295d84e1d084c6b79c239097010bc64a3874e37e4a38e6.zip
@aws-cdk-testing/framework-integ:       
@aws-cdk-testing/framework-integ:       
@aws-cdk-testing/framework-integ: Snapshot Results: 
@aws-cdk-testing/framework-integ: Tests:    1 failed, 1333 total
@aws-cdk-testing/framework-integ: Failed: /codebuild/output/src3908876137/src/actions-runner/_work/aws-cdk/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.latest.js
@aws-cdk-testing/framework-integ: Error: Some tests failed!

click Update branch to merge the latest changes from main, git pull and try again. It might be due to some previous merged commits.

image

@azatoth
Copy link
Copy Markdown
Contributor Author

azatoth commented Jan 7, 2026

click Update branch to merge the latest changes from main, git pull and try again. It might be due to some previous merged commits.
image

I've updated the branch again now (rebase); I did do this several times before, hoping it had been fixed.

@azatoth azatoth force-pushed the regex-conditions branch 3 times, most recently from bf3fb17 to fafe14e Compare January 7, 2026 17:37
@azatoth
Copy link
Copy Markdown
Contributor Author

azatoth commented Jan 7, 2026

@pahud I noticed I had updated yarn.lock, and reverting that seems to solve the issue.

@azatoth azatoth force-pushed the regex-conditions branch 3 times, most recently from a69b63d to 01ce9cb Compare January 17, 2026 09:32
@azatoth azatoth force-pushed the regex-conditions branch 3 times, most recently from f6a2303 to ffbb566 Compare March 1, 2026 09:01
@azatoth azatoth force-pushed the regex-conditions branch from ffbb566 to 4275238 Compare March 6, 2026 08:08
@azatoth azatoth force-pushed the regex-conditions branch 2 times, most recently from c09bc56 to 1c00163 Compare March 18, 2026 09:51
Add regex-based condition methods for ALB listener rules:
- hostHeadersRegex() for host header pattern matching
- httpHeaderRegex() for HTTP header pattern matching
- pathPatternsRegex() for URL path pattern matching

These methods use the regexValues CloudFormation property instead
of values, allowing for more flexible pattern matching using regular
expressions.

Also add comprehensive validation for all listener condition types:
- Maximum length validation (128 chars for most values, 40 for header names)
- Non-empty value validation where required
- Pattern validation for HTTP request methods
- Maximum count validation (5 items for path patterns)

Includes unit tests and integration tests for all new functionality.

closes aws#36363
Copy link
Copy Markdown
Contributor

@hoegertn hoegertn left a comment

Choose a reason for hiding this comment

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

LGTM; looking forward to the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(elasticloadbalancingv2): Allow regex path patterns

4 participants