-
Notifications
You must be signed in to change notification settings - Fork 4.5k
elasticloadbalancingv2: add validation for path parameter of ListenerAction.redirect() #31201
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-elasticloadbalancingv2Related to Amazon Elastic Load Balancing V2Related to Amazon Elastic Load Balancing V2effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2
Description
Describe the feature
When setting the path property for ListenerAction.redirect(), CDK will validate whether it starts with a /.
Use Case
If we set a string without a leading / for the path property, deployment will fail as shown below.
Given:
httpListener.addAction('RedirectAction', {
conditions: [elbv2.ListenerCondition.pathPatterns(['/*'])],
action: elbv2.ListenerAction.redirect({
protocol: elbv2.ApplicationProtocol.HTTPS,
path: 'example/path? ',
permanent: true
}),
})Result:
Failed resources:
MainStack-develop | 1:34:02 AM | CREATE_FAILED | AWS::ElasticLoadBalancingV2::ListenerRule | Alb/HttpListener/RedirectActionRule (AlbHttpListenerRedirectActionRule1D930694) Internal error reported from downstream service during operation 'The Path parameter must be a valid path, should start with a '/', and may contain up to one of each of these placeholders: '#{path}', '#{host}', '#{port}'. (Service: ElasticLoadBalancingV2, Status Code: 400, Request ID: fd4c7f01-9c97-44c1-a177-30ac04b2db26)'.Proposed Solution
Add validation for path prop like below.
if (options.path && !options.path.startsWith('/')) {
throw new Error('Redirect path must start with a \'/\'');
}Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.150.0
Environment details (OS name and version, etc.)
irrelevant
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-elasticloadbalancingv2Related to Amazon Elastic Load Balancing V2Related to Amazon Elastic Load Balancing V2effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2