Skip to content

Commit

Permalink
fix(aws-ecs): fix healthCheckGracePeriodSeconds (#1266)
Browse files Browse the repository at this point in the history
Respect grace peridos parameter.

Fixes #1265.
  • Loading branch information
rix0rrr committed Dec 5, 2018
1 parent 5004f50 commit 3a89e21
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export abstract class BaseService extends cdk.Construct
maximumPercent: props.maximumPercent || 200,
minimumHealthyPercent: props.minimumHealthyPercent || 50
},
healthCheckGracePeriodSeconds: props.healthCheckGracePeriodSeconds,
/* role: never specified, supplanted by Service Linked Role */
networkConfiguration: new cdk.Token(() => this.networkConfiguration),
...additionalProps
Expand Down
30 changes: 29 additions & 1 deletion packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/cdk');
import { Test } from 'nodeunit';
import ecs = require('../../lib');
import { ContainerImage } from '../../lib';

export = {
"When creating a Fargate Service": {
Expand Down Expand Up @@ -127,5 +128,32 @@ export = {

test.done();
},
}
},

"When setting up a health check": {
'grace period is respected'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');
taskDefinition.addContainer('MainContainer', {
image: ContainerImage.fromDockerHub('hello'),
});

// WHEN
new ecs.FargateService(stack, 'Svc', {
cluster,
taskDefinition,
healthCheckGracePeriodSeconds: 10
});

// THEN
expect(stack).to(haveResource('AWS::ECS::Service', {
HealthCheckGracePeriodSeconds: 10
}));

test.done();
},
},
};

0 comments on commit 3a89e21

Please sign in to comment.