Skip to content

Commit

Permalink
fix(elasticloadbalancingv2): fix to be able to set deregistrationDelay (
Browse files Browse the repository at this point in the history
  • Loading branch information
cohalz authored and Elad Ben-Israel committed Jun 30, 2019
1 parent 629e963 commit 22ab4b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export abstract class TargetGroupBase extends cdk.Construct implements ITargetGr
super(scope, id);

if (baseProps.deregistrationDelay !== undefined) {
this.setAttribute('deregistration_delay.timeout_seconds', baseProps.deregistrationDelay.toString());
this.setAttribute('deregistration_delay.timeout_seconds', baseProps.deregistrationDelay.toSeconds().toString());
}

this.healthCheck = baseProps.healthCheck || {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, haveResource, MatchStyle } from '@aws-cdk/assert';
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/core');
import { ConstructNode } from '@aws-cdk/core';
import { ConstructNode, Duration } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import elbv2 = require('../../lib');
import { FakeSelfRegisteringTarget } from '../helpers';
Expand Down Expand Up @@ -534,6 +534,31 @@ export = {
test.done();
},

'Can configure deregistration_delay for targets'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Stack');

// WHEN
new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
vpc,
port: 80,
deregistrationDelay: Duration.seconds(30)
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetGroupAttributes: [
{
Key: "deregistration_delay.timeout_seconds",
Value: "30"
}
]
}));

test.done();
},

'Throws with bad fixed responses': {

'status code'(test: Test) {
Expand Down

0 comments on commit 22ab4b4

Please sign in to comment.