Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecs-patterns): support min and max health percentage in queueprocessingservice #8312

Merged
merged 2 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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