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

elasticloadbalancingv2: add validation for path parameter of ListenerAction.redirect() #31201

Closed
1 of 2 tasks
badmintoncryer opened this issue Aug 23, 2024 · 3 comments · Fixed by #31202
Closed
1 of 2 tasks
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@badmintoncryer
Copy link
Contributor

badmintoncryer commented Aug 23, 2024

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)'.

Related docs: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-listenerrule-redirectconfig.html#cfn-elasticloadbalancingv2-listenerrule-redirectconfig-path

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

@badmintoncryer badmintoncryer added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 23, 2024
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Aug 23, 2024
@pahud pahud removed the needs-triage This issue or PR still needs to be triaged. label Aug 23, 2024
@pahud pahud self-assigned this Aug 23, 2024
@pahud
Copy link
Contributor

pahud commented Aug 23, 2024

Thank you for the PR as always @badmintoncryer !

@pahud pahud added the p2 label Aug 23, 2024
@pahud pahud removed their assignment Aug 23, 2024
@pahud pahud added the effort/small Small work item – less than a day of effort label Aug 23, 2024
@mergify mergify bot closed this as completed in #31202 Sep 13, 2024
@mergify mergify bot closed this as completed in bf3764f Sep 13, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants