feat(elasticloadbalancingv2): transforms for ALB listener rule#35906
Open
badmintoncryer wants to merge 61 commits intoaws:mainfrom
Open
feat(elasticloadbalancingv2): transforms for ALB listener rule#35906badmintoncryer wants to merge 61 commits intoaws:mainfrom
badmintoncryer wants to merge 61 commits intoaws:mainfrom
Conversation
aws-cdk-automation
previously requested changes
Oct 31, 2025
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
badmintoncryer
commented
Oct 31, 2025
| */ | ||
| @MethodMetadata() | ||
| public addAction(id: string, props: AddApplicationActionProps): void { | ||
| checkAddRuleProps(this, props); |
Contributor
Author
There was a problem hiding this comment.
Because checkAddRuleProps() cannot accept transforms prop, I've added new validation function checkAddActionProps().
badmintoncryer
commented
Oct 31, 2025
| } | ||
|
|
||
| private validateRewrites(rewrites: RewriteRule[]): void { | ||
| if (rewrites.length !== 1) { |
Contributor
Author
There was a problem hiding this comment.
In CloudFormation, an array of rewrite rules can be configured, but currently, deploying with multiple rules results in an error.
To prepare for future enhancements, the parameter is defined to accept an array, while validation restricts the number of elements to one.
transforms: [
elbv2.ListenerTransform.hostHeaderRewrite([
{
regex: '^(.*)\\.example\\.com$',
replace: '$1.internal.example.com',
},
{
regex: '^(.*)$',
replace: 'internal.example.com',
},
]),
],Resource handler returned message: "Rule transforms must have exactly one Rewrite (Service: ElasticLoadBalancingV2, Status Code: 400, Request ID: c2ecd108-daad-4c23-bc38-0c5b1348d04a) (SDK Attempt Count: 1)" (RequestToken: d66a6b69-d5c8-2d95-a439-4f422e5905c9, HandlerErrorCode: InvalidRequest)…ror calls After merging main, the error constructors now require a name parameter as the first argument. Updated all 8 call sites in the transforms feature. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…g error names in transforms String literals passed directly to ValidationError/UnscopedValidationError are not assignable to the branded LiteralString type; wrap each error name with the lit tagged template function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
None
Reason for this change
ALB now supports for modifying host header and URL information. This feature has already supporrted by cloudformation.
https://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/application/rule-transforms.html
Description of changes
ListenerTransformclass with factory methods:hostHeaderRewrite(): Transform host headers using regexpatterns
urlRewrite(): Transform URL paths using regex patternsAddApplicationActionPropsaddTransform()method toApplicationListenerRulerule
Describe any new or updated permissions being added
None
Description of how you validated changes
Add both unit and integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license