Skip to content

[aws_elasticloadbalancingv2]: Target Group 'slowStart' option can't be disabled  #29437

@frfavoreto

Description

@frfavoreto

Describe the bug

When you set slowStart attribute on a Target Group it sets this property correctly in the CFN template:

const targetGroup = httpListener.addTargets('myTG', {
      protocol: elbv2.ApplicationProtocol.HTTP,
      slowStart: cdk.Duration.seconds(40),
    });

Template:

"TargetGroup52DC4313": {
   "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
   "Properties": {
   .
   .
   .
    "TargetGroupAttributes": [
     {
      "Key": "slow_start.duration_seconds",
      "Value": "40"
     }

But when trying to remove this setting by just removing slowStart attribute, CDK removes the synthesized attribute from the CFN template but the actual ElbV2 Target Group resource is not changed.

In the docs the default value would be set to "0" (disabled) but it doesn't accept anything outside the 30-900 range:

Error: Slow start duration value must be between 30 and 900 seconds.

The only way to disable it is by directly changing the Target Group Attributes from AWS Console/CLI.

Expected Behavior

Slow Start attribute removed from the ElbV2 Target Group by either removing 'slowStart' option from the construct's properties or by setting it to "0" (slowStart: cdk.Duration.seconds(0))

Current Behavior

Slow Start attribute can not be removed from CDK. Not possible to set it to "0".

Reproduction Steps

1 - Create ALB, Listener and Target Group (with slowStart property set)

const vpc = new ec2.Vpc(this, 'myVPC', {
      maxAzs: 2,
    });

    const alb = new elbv2.ApplicationLoadBalancer(this, 'myALB', {
      vpc: vpc,
    });

    const httpListener = alb.addListener('myListener-http', { 
      protocol: elbv2.ApplicationProtocol.HTTP,
    });

    const targetGroup = httpListener.addTargets('myTG', {
      protocol: elbv2.ApplicationProtocol.HTTP,
      slowStart: cdk.Duration.seconds(40),
    });

2 - Try removing 'slowStart' property and it deploys successfully, but Target Group resource keeps it enabled. Or try to set it to "0" and CDK does not allow it.

Possible Solution

Allow "0" in the range for cdk.Duration.seconds() values and implicitly synthesize the Target Group resource with this as default when slowStart attribute is omited (if previously enabled):

"TargetGroupAttributes": [ { "Key": "slow_start.duration_seconds", "Value": "0" }

Additional Information/Context

No response

CDK CLI Version

All supported versions, including latest 2.132.0

Framework Version

No response

Node.js Version

16

OS

Mac

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-elasticloadbalancingv2Related to Amazon Elastic Load Balancing V2bugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions