diff --git a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts index 351c90592a240..ba434018de764 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts @@ -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 diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts index b3405a54ac9dd..b523ce4a3dbbd 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts @@ -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": { @@ -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(); + }, + }, };