diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index d61567e55670e..f3dbf3202850b 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -6,8 +6,7 @@ import { ICluster, LogDriver, PropagatedTagSource, Secret, } from '../../../aws-ecs'; import { IQueue, Queue } from '../../../aws-sqs'; -import { CfnOutput, Duration, FeatureFlags, Stack } from '../../../core'; -import * as cxapi from '../../../cx-api'; +import { CfnOutput, Duration, Stack } from '../../../core'; /** * The properties for the base QueueProcessingEc2Service or QueueProcessingFargateService service. @@ -55,15 +54,6 @@ export interface QueueProcessingServiceBaseProps { */ readonly command?: string[]; - /** - * The desired number of instantiations of the task definition to keep running on the service. - * - * @default - The minScalingCapacity is 1 for all new services and uses the existing services desired count - * when updating an existing service. - * @deprecated - Use `minScalingCapacity` or a literal object instead. - */ - readonly desiredTaskCount?: number; - /** * Flag to indicate whether to enable logging. * @@ -286,12 +276,6 @@ export abstract class QueueProcessingServiceBase extends Construct { */ public readonly secrets?: { [key: string]: Secret }; - /** - * The minimum number of tasks to run. - * @deprecated - Use `minCapacity` instead. - */ - public readonly desiredCount: number; - /** * The maximum number of instances for autoscaling to scale up to. */ @@ -381,25 +365,8 @@ export abstract class QueueProcessingServiceBase extends Construct { this.disableCpuBasedScaling = props.disableCpuBasedScaling ?? false; this.cpuTargetUtilizationPercent = props.cpuTargetUtilizationPercent ?? 50; - this.desiredCount = props.desiredTaskCount ?? 1; - - // Determine the desired task count (minimum) and maximum scaling capacity - if (!FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT)) { - this.minCapacity = props.minScalingCapacity ?? this.desiredCount; - this.maxCapacity = props.maxScalingCapacity || (2 * this.desiredCount); - } else { - if (props.desiredTaskCount != null) { - this.minCapacity = props.minScalingCapacity ?? this.desiredCount; - this.maxCapacity = props.maxScalingCapacity || (2 * this.desiredCount); - } else { - this.minCapacity = props.minScalingCapacity ?? 1; - this.maxCapacity = props.maxScalingCapacity || 2; - } - } - - if (!this.desiredCount && !this.maxCapacity) { - throw new Error('maxScalingCapacity must be set and greater than 0 if desiredCount is 0'); - } + this.minCapacity = props.minScalingCapacity ?? 1; + this.maxCapacity = props.maxScalingCapacity || 2; new CfnOutput(this, 'SQSQueue', { value: this.sqsQueue.queueName }); new CfnOutput(this, 'SQSQueueArn', { value: this.sqsQueue.queueArn }); diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts index 8ddce9b40419d..30421b070b01b 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts @@ -1,7 +1,5 @@ import { Construct } from 'constructs'; import { Ec2Service, Ec2TaskDefinition, PlacementConstraint, PlacementStrategy } from '../../../aws-ecs'; -import { FeatureFlags } from '../../../core'; -import * as cxapi from '../../../cx-api'; import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base'; /** @@ -128,14 +126,10 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase { logging: this.logDriver, }); - // The desiredCount should be removed from the fargate service when the feature flag is removed. - const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount; - // Create an ECS service with the previously defined Task Definition and configure // autoscaling based on cpu utilization and number of messages visible in the SQS queue. this.service = new Ec2Service(this, 'QueueProcessingService', { cluster: this.cluster, - desiredCount: desiredCount, taskDefinition: this.taskDefinition, serviceName: props.serviceName, minHealthyPercent: props.minHealthyPercent, diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index 77d28ea2821d0..29d1cb267beb1 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -1,8 +1,6 @@ import { Construct } from 'constructs'; import * as ec2 from '../../../aws-ec2'; import { FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; -import { FeatureFlags } from '../../../core'; -import * as cxapi from '../../../cx-api'; import { FargateServiceBaseProps } from '../base/fargate-service-base'; import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base'; @@ -95,14 +93,10 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { throw new Error('You must specify one of: taskDefinition or image'); } - // The desiredCount should be removed from the fargate service when the feature flag is removed. - const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount; - // Create a Fargate service with the previously defined Task Definition and configure // autoscaling based on cpu utilization and number of messages visible in the SQS queue. this.service = new FargateService(this, 'QueueProcessingFargateService', { cluster: this.cluster, - desiredCount: desiredCount, taskDefinition: this.taskDefinition, serviceName: props.serviceName, minHealthyPercent: props.minHealthyPercent, diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts index 66844caceb3bd..bce8ce7704b3c 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts @@ -352,30 +352,6 @@ testDeprecated('test ECS queue worker service construct - with optional props', }); }); -testDeprecated('throws if desiredTaskCount and maxScalingCapacity are 0', () => { - // GIVEN - const stack = new cdk.Stack(); - const vpc = new ec2.Vpc(stack, 'VPC'); - const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }), - })); - - // THEN - expect(() => - new ecsPatterns.QueueProcessingEc2Service(stack, 'Service', { - cluster, - desiredTaskCount: 0, - memoryLimitMiB: 512, - image: ecs.ContainerImage.fromRegistry('test'), - }), - ).toThrow(/maxScalingCapacity must be set and greater than 0 if desiredCount is 0/); -}); - test('can set custom containerName', () => { // GIVEN const stack = new cdk.Stack();