Skip to content

Commit 22ab4b4

Browse files
cohalzElad Ben-Israel
authored and
Elad Ben-Israel
committed
fix(elasticloadbalancingv2): fix to be able to set deregistrationDelay (#3075)
1 parent 629e963 commit 22ab4b4

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export abstract class TargetGroupBase extends cdk.Construct implements ITargetGr
205205
super(scope, id);
206206

207207
if (baseProps.deregistrationDelay !== undefined) {
208-
this.setAttribute('deregistration_delay.timeout_seconds', baseProps.deregistrationDelay.toString());
208+
this.setAttribute('deregistration_delay.timeout_seconds', baseProps.deregistrationDelay.toSeconds().toString());
209209
}
210210

211211
this.healthCheck = baseProps.healthCheck || {};

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.listener.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, haveResource, MatchStyle } from '@aws-cdk/assert';
22
import ec2 = require('@aws-cdk/aws-ec2');
33
import cdk = require('@aws-cdk/core');
4-
import { ConstructNode } from '@aws-cdk/core';
4+
import { ConstructNode, Duration } from '@aws-cdk/core';
55
import { Test } from 'nodeunit';
66
import elbv2 = require('../../lib');
77
import { FakeSelfRegisteringTarget } from '../helpers';
@@ -534,6 +534,31 @@ export = {
534534
test.done();
535535
},
536536

537+
'Can configure deregistration_delay for targets'(test: Test) {
538+
// GIVEN
539+
const stack = new cdk.Stack();
540+
const vpc = new ec2.Vpc(stack, 'Stack');
541+
542+
// WHEN
543+
new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
544+
vpc,
545+
port: 80,
546+
deregistrationDelay: Duration.seconds(30)
547+
});
548+
549+
// THEN
550+
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
551+
TargetGroupAttributes: [
552+
{
553+
Key: "deregistration_delay.timeout_seconds",
554+
Value: "30"
555+
}
556+
]
557+
}));
558+
559+
test.done();
560+
},
561+
537562
'Throws with bad fixed responses': {
538563

539564
'status code'(test: Test) {

0 commit comments

Comments
 (0)