-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
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