Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

aws-elasticloadbalancingv2: How to achieve path-based and weighted target group routing from ALB to multiple services? #28313

Closed
gokulanv opened this issue Dec 9, 2023 · 1 comment
Assignees
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 documentation This is a problem with documentation.

Comments

@gokulanv
Copy link

gokulanv commented Dec 9, 2023

Describe the issue

I have service A with two pipeline prod stages: 1-box serves 10% traffic and full-prod that serves 90% traffic.
Now, I want to add Service B to the same cluster and implement path based routing.

ALB 
        -> Path: /svcA -> TargetGroup-SvcA-1Box: Service A (1-box stage 10% traffic)
        -> Path: /svcA -> TargetGroup-SvcA-FullProd: Service A (full-prod stage 90% traffic)
        -> Path: /svcB -> TargetGroup-SvcB-1Box: Service B (1-box stage 10% traffic)
        -> Path: /svcB -> TargetGroup-SvcB-FullProd: Service B (full-prod stage 90% traffic)

Can you point me to CDK examples of how I can do this? I dont see enough documentation to support both path-based and weight based service routing from ALB. At the bare minimum, would like to know step by step guidelines with constructs to use.

Links

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-update-rules.html

@gokulanv gokulanv added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Dec 9, 2023
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Dec 9, 2023
@tim-finnigan
Copy link

Hi @gokulanv thanks for reaching out. Here is the CDK documentation for aws-elasticloadbalancingv2: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2-readme.html.

You can find more info there for your use case, for example:

declare const listener: elbv2.ApplicationListener;
declare const asg: autoscaling.AutoScalingGroup;

listener.addTargets('Example.Com Fleet', {
  priority: 10,
  conditions: [
    elbv2.ListenerCondition.hostHeaders(['example.com']),
    elbv2.ListenerCondition.pathPatterns(['/ok', '/path']),
  ],
  port: 8080,
  targets: [asg]
});

Also:

  • Weighted Target Groups: use ListenerAction.weightedForward() to give different weights to different target groups.

I hope that helps. I'm going to convert this issue into a discussion since it involves a general question. Others from the community are welcome to share feedback here as well.

@tim-finnigan tim-finnigan self-assigned this Dec 11, 2023
@tim-finnigan tim-finnigan removed the needs-triage This issue or PR still needs to be triaged. label Dec 11, 2023
@aws aws locked and limited conversation to collaborators Dec 11, 2023
@tim-finnigan tim-finnigan converted this issue into discussion #28334 Dec 11, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 documentation This is a problem with documentation.
Projects
None yet
Development

No branches or pull requests

2 participants