Skip to content

Commit

Permalink
feat(aws-ecs-patterns): adding min and max halth percentage to queue-…
Browse files Browse the repository at this point in the history
…processing fargate service

fixes: #8277
  • Loading branch information
plastic-karma committed Jun 3, 2020
1 parent a8b1815 commit ea80fb8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/@aws-cdk/aws-ecs-patterns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,22 @@ scalableTarget.scaleOnMemoryUtilization('MemoryScaling', {
targetUtilizationPercent: 50,
});
```

### Set deployment configuration on QueueProcessingService

```ts
const queueProcessingFargateService = new QueueProcessingFargateService(stack, 'Service', {
cluster,
memoryLimitMiB: 512,
image: ecs.ContainerImage.fromRegistry('test'),
command: ["-c", "4", "amazon.com"],
enableLogging: false,
desiredTaskCount: 2,
environment: {},
queue,
maxScalingCapacity: 5,
maxHealthyPercent: 200,
minHealthPercent: 66,
});
```

Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ export interface QueueProcessingServiceBaseProps {
* @default - Automatically generated name.
*/
readonly family?: string;

/**
* The maximum number of tasks, specified as a percentage of the Amazon ECS
* service's DesiredCount value, that can run in a service during a
* deployment.
*
* @default - default from underlying service.
*/
readonly maxHealthyPercent?: number;

/**
* The minimum number of tasks, specified as a percentage of
* the Amazon ECS service's DesiredCount value, that must
* continue to run and remain healthy during a deployment.
*
* @default - default from underlying service.
*/
readonly minHealthyPercent?: number;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase {
desiredCount: this.desiredCount,
taskDefinition: this.taskDefinition,
serviceName: props.serviceName,
minHealthyPercent: props.minHealthyPercent,
maxHealthyPercent: props.maxHealthyPercent,
propagateTags: props.propagateTags,
enableECSManagedTags: props.enableECSManagedTags,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
desiredCount: this.desiredCount,
taskDefinition: this.taskDefinition,
serviceName: props.serviceName,
minHealthyPercent: props.minHealthyPercent,
maxHealthyPercent: props.maxHealthyPercent,
propagateTags: props.propagateTags,
enableECSManagedTags: props.enableECSManagedTags,
platformVersion: props.platformVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,19 @@ export = {
},
queue,
maxScalingCapacity: 5,
minHealthyPercent: 60,
maxHealthyPercent: 150,
serviceName: 'ecs-test-service',
family: 'ecs-task-family',
});

// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all optional properties are set.
expect(stack).to(haveResource('AWS::ECS::Service', {
DesiredCount: 2,
DeploymentConfiguration: {
MinimumHealthyPercent: 60,
MaximumPercent: 150,
},
LaunchType: 'EC2',
ServiceName: 'ecs-test-service',
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ export = {
},
queue,
maxScalingCapacity: 5,
minHealthyPercent: 60,
maxHealthyPercent: 150,
serviceName: 'fargate-test-service',
family: 'fargate-task-family',
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
Expand All @@ -231,6 +233,10 @@ export = {
// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set.
expect(stack).to(haveResource('AWS::ECS::Service', {
DesiredCount: 2,
DeploymentConfiguration: {
MinimumHealthyPercent: 60,
MaximumPercent: 150,
},
LaunchType: 'FARGATE',
ServiceName: 'fargate-test-service',
PlatformVersion: ecs.FargatePlatformVersion.VERSION1_4,
Expand Down

0 comments on commit ea80fb8

Please sign in to comment.