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

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

Closed
frfavoreto opened this issue Mar 11, 2024 · 3 comments · Fixed by #29445 · May be fixed by NOUIY/aws-solutions-constructs#98, NOUIY/aws-solutions-constructs#99 or NOUIY/aws-solutions-constructs#101
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@frfavoreto
Copy link

frfavoreto commented Mar 11, 2024

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

@frfavoreto frfavoreto added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 11, 2024
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Mar 11, 2024
@frfavoreto frfavoreto changed the title [aws_elasticloadbalancingv2]: Target Group 'slowStart' option can't be unset [aws_elasticloadbalancingv2]: Target Group 'slowStart' option can't be disabled Mar 11, 2024
@pahud
Copy link
Contributor

pahud commented Mar 11, 2024

According to the doc:

slow_start.duration_seconds - The time period, in seconds, during which a newly registered target receives an increasing share of the traffic to the target group. After this time period ends, the target receives its full share of traffic. The range is 30-900 seconds (15 minutes). The default is 0 seconds (disabled).

I think we should fix it here to allow explicitly 0 to disable it.

if (props.slowStart.toSeconds() < 30 || props.slowStart.toSeconds() > 900) {
throw new Error('Slow start duration value must be between 30 and 900 seconds.');
}

@pahud pahud added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 11, 2024
@msambol
Copy link
Contributor

msambol commented Mar 11, 2024

I'll take this.

@mergify mergify bot closed this as completed in #29445 Mar 18, 2024
mergify bot pushed a commit that referenced this issue Mar 18, 2024
…ds (#29445)

Closes #29437.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

ahammond pushed a commit to ahammond/aws-cdk that referenced this issue Mar 26, 2024
…ds (aws#29445)

Closes aws#29437.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
3 participants