Skip to content

Commit 5f41f61

Browse files
committed
feat(aws-ecs-patterns): adding min and max halth percentage to queue-processing fargate service
fixes: #8277
1 parent a8b1815 commit 5f41f61

5 files changed

+34
-0
lines changed

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

+18
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ export interface QueueProcessingServiceBaseProps {
147147
* @default - Automatically generated name.
148148
*/
149149
readonly family?: string;
150+
151+
/**
152+
* The maximum number of tasks, specified as a percentage of the Amazon ECS
153+
* service's DesiredCount value, that can run in a service during a
154+
* deployment.
155+
*
156+
* @default - default from underlying service.
157+
*/
158+
readonly maxHealthyPercent?: number;
159+
160+
/**
161+
* The minimum number of tasks, specified as a percentage of
162+
* the Amazon ECS service's DesiredCount value, that must
163+
* continue to run and remain healthy during a deployment.
164+
*
165+
* @default - default from underlying service.
166+
*/
167+
readonly minHealthyPercent?: number;
150168
}
151169

152170
/**

packages/@aws-cdk/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase {
9696
desiredCount: this.desiredCount,
9797
taskDefinition: this.taskDefinition,
9898
serviceName: props.serviceName,
99+
minHealthyPercent: props.minHealthyPercent,
100+
maxHealthyPercent: props.maxHealthyPercent,
99101
propagateTags: props.propagateTags,
100102
enableECSManagedTags: props.enableECSManagedTags,
101103
});

packages/@aws-cdk/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
101101
desiredCount: this.desiredCount,
102102
taskDefinition: this.taskDefinition,
103103
serviceName: props.serviceName,
104+
minHealthyPercent: props.minHealthyPercent,
105+
maxHealthyPercent: props.maxHealthyPercent,
104106
propagateTags: props.propagateTags,
105107
enableECSManagedTags: props.enableECSManagedTags,
106108
platformVersion: props.platformVersion,

packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.queue-processing-ecs-service.ts

+6
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,19 @@ export = {
179179
},
180180
queue,
181181
maxScalingCapacity: 5,
182+
minHealthyPercent: 60,
183+
maxHealthyPercent: 150,
182184
serviceName: 'ecs-test-service',
183185
family: 'ecs-task-family',
184186
});
185187

186188
// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all optional properties are set.
187189
expect(stack).to(haveResource('AWS::ECS::Service', {
188190
DesiredCount: 2,
191+
DeploymentConfiguration: {
192+
MinimumHealthyPercent: 60,
193+
MaximumPercent: 150,
194+
},
189195
LaunchType: 'EC2',
190196
ServiceName: 'ecs-test-service',
191197
}));

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

+6
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ export = {
223223
},
224224
queue,
225225
maxScalingCapacity: 5,
226+
minHealthyPercent: 60,
227+
maxHealthyPercent: 150,
226228
serviceName: 'fargate-test-service',
227229
family: 'fargate-task-family',
228230
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
@@ -231,6 +233,10 @@ export = {
231233
// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set.
232234
expect(stack).to(haveResource('AWS::ECS::Service', {
233235
DesiredCount: 2,
236+
DeploymentConfiguration: {
237+
MinimumHealthyPercent: 60,
238+
MaximumPercent: 150,
239+
},
234240
LaunchType: 'FARGATE',
235241
ServiceName: 'fargate-test-service',
236242
PlatformVersion: ecs.FargatePlatformVersion.VERSION1_4,

0 commit comments

Comments
 (0)