Skip to content

Commit 3a89e21

Browse files
authored
fix(aws-ecs): fix healthCheckGracePeriodSeconds (#1266)
Respect grace peridos parameter. Fixes #1265.
1 parent 5004f50 commit 3a89e21

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

packages/@aws-cdk/aws-ecs/lib/base/base-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export abstract class BaseService extends cdk.Construct
111111
maximumPercent: props.maximumPercent || 200,
112112
minimumHealthyPercent: props.minimumHealthyPercent || 50
113113
},
114+
healthCheckGracePeriodSeconds: props.healthCheckGracePeriodSeconds,
114115
/* role: never specified, supplanted by Service Linked Role */
115116
networkConfiguration: new cdk.Token(() => this.networkConfiguration),
116117
...additionalProps

packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ec2 = require('@aws-cdk/aws-ec2');
33
import cdk = require('@aws-cdk/cdk');
44
import { Test } from 'nodeunit';
55
import ecs = require('../../lib');
6+
import { ContainerImage } from '../../lib';
67

78
export = {
89
"When creating a Fargate Service": {
@@ -127,5 +128,32 @@ export = {
127128

128129
test.done();
129130
},
130-
}
131+
},
132+
133+
"When setting up a health check": {
134+
'grace period is respected'(test: Test) {
135+
// GIVEN
136+
const stack = new cdk.Stack();
137+
const vpc = new ec2.VpcNetwork(stack, 'MyVpc', {});
138+
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
139+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');
140+
taskDefinition.addContainer('MainContainer', {
141+
image: ContainerImage.fromDockerHub('hello'),
142+
});
143+
144+
// WHEN
145+
new ecs.FargateService(stack, 'Svc', {
146+
cluster,
147+
taskDefinition,
148+
healthCheckGracePeriodSeconds: 10
149+
});
150+
151+
// THEN
152+
expect(stack).to(haveResource('AWS::ECS::Service', {
153+
HealthCheckGracePeriodSeconds: 10
154+
}));
155+
156+
test.done();
157+
},
158+
},
131159
};

0 commit comments

Comments
 (0)