Skip to content

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

@vcschapp

Description

@vcschapp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions