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): Configure cross-zone load balancing for ALB target groups #31790

Closed
2 tasks
vcschapp opened this issue Oct 17, 2024 · 6 comments · Fixed by #31814
Closed
2 tasks

(elasticloadbalancingv2): Configure cross-zone load balancing for ALB target groups #31790

vcschapp opened this issue Oct 17, 2024 · 6 comments · Fixed by #31814
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

@vcschapp
Copy link

vcschapp commented Oct 17, 2024

Describe the feature

Expose ALB's existing ability to turn off cross-zone load balancing for ALB target groups, as described in more detail in the Other Information section.

Use Case

  1. As an engineer, I want to build a resilient backend service with control over which availability zones my customer requests are routed to, but I can't because CDK hides ALB's ability to control cross-zone load balancing at the target group level.
  2. I'm always frustrated when CDK does not have feature parity with CloudFormation, especially when, as in this case, there is no usable workaround.

Proposed Solution

The constructor for CDK's ApplicationTargetGroup construct should accept a crossZoneEnabled: boolean flag in the existing constructor props structure, ApplicationTargetGroupProps.

Other Information

Feature supported in ALB

Since November 17, 2022, Application Load Balancers now support turning off cross zone load balancing per target group. See also the Cross-zone load balancing heading on the How Elastic Load Balancing Works user guide page.

Feature supported in CloudFormation

This feature can be used in CloudFormation by setting the following target group attribute:

{
  "Key": "load_balancing.cross_zone.enabled",
  "Value": "false"
}

under the TargetGroupAttributes property within an AWS::ElasticLoadBalancingV2::TargetGroup resource properties.

No workaround in CDK

In theory, you can workaround this issue in CDK using the CfnTargetGroup.addOverride. However, because adding overrides would entirely replace the values CDK wants to put for the target group attributes, in practice this means adding overrides would force me to replicate CDK's entire logic for target group attributes. This is incredibly frustrating.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.162.1

Environment details (OS name and version, etc.)

Ubuntu Linux 20.04

@vcschapp vcschapp added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2024
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Oct 17, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2024
@khushail khushail self-assigned this Oct 17, 2024
@khushail
Copy link
Contributor

Hi @vcschapp , thansk for reaching out.

I see the related issue of configuring cross-zone load balancing false for ALB target groups has been discussed here in detail s-#29866 (comment)

and a corresponding Workaround was also suggested for target groups-#29866 (comment).
There is a PR submissions as well- crossZoneEnabled does not support false for ALB.

Request you to take a look and get back if this does not solve the usecase you are referring to.

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Oct 17, 2024
@vcschapp
Copy link
Author

vcschapp commented Oct 18, 2024

@khushail thanks.

The issue you referenced is not related (#31790) and the PR you referenced does not fix the problem (#29907).

In issue #31790, the user is requesting to turn off cross-zone at the ALB level, which is not possible.

The workaround indicated by codypenta@ doesn't work for me in general because, as I mentioned in the main issue text:

In theory, you can workaround this issue in CDK using the CfnTargetGroup.addOverride. However, because adding overrides would entirely replace the values CDK wants to put for the target group attributes, in practice this means adding overrides would force me to replicate CDK's entire logic for target group attributes.

My understanding of the code in CfnResource.addOverride is that there is no way to supplement keys added by CDK. If you use addOverride you are replacing what CDK puts there.

The description for PR #29907 says:

This PR covers the following cases:

...

3/ When crossZoneEnabled is false with ALB, cdk throws an error because ALB does not support disabling it per doc description.

So basically the PR makes CDK throw an exception when you try to turn off cross-zone for ALB at the load balancer level. This is fine, as ALB doesn't support that. But that's not what my issue is about. My issue is about disabling cross-zone at the target group level, which ALB does support, and CloudFormation supports, but CDK does not.

@khushail
Copy link
Contributor

khushail commented Oct 18, 2024

@vcschapp , thanks so much for explaining that so well and getting back.

I understood your point and confirm that its supported by cloudformation as well - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute.html#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-key

So till it is implemented , as a workaround, this should be achievable with Escape hatches using L1 construct.

I would be marking this as P2 which means it won't be immediately addresed by the team but would be on their radar and for keeping it open for contribution from community as well as from the team as well.

Thanks.

@khushail khushail added effort/small Small work item – less than a day of effort and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Oct 18, 2024
@khushail khushail removed their assignment Oct 18, 2024
@vcschapp
Copy link
Author

Thanks @khushail, I appreciate the updates.

Btw, it looks like @mazyu36 already has a PR out to potentially fix it!

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 Nov 14, 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