From 704f596539372364408b6bff83e21221b6bb0970 Mon Sep 17 00:00:00 2001 From: Jess Izen <44884346+jlizen@users.noreply.github.com> Date: Mon, 4 Mar 2024 03:21:46 -0800 Subject: [PATCH] docs(ecs-patterns): remove references to REMOVE_DEFAULT_DESIRED_COUNT (#29344) ### Issue # (if applicable) Closes # 29325 ### Reason for this change The `REMOVE_DEFAULT_DESIRED_COUNT` feature flag is always enabled in CDKv2, and throws builds errors if explicitly set. The `ecs-patterns` docs still reference it as "opt-in", which is misleading. Ref: [list of deprecated feature flags for v2](https://github.com/aws/aws-cdk/blob/3cbad4a2164a41f5529e04aba4d15085c71b7849/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md?plain=1#L145) See [Issue 29325](https://github.com/aws/aws-cdk/issues/29325) for a sample build error when trying to follow the current example code in docs for enabling the flag. I did NOT remove the actual conditionals in the construct code, that check the (now always true) feature flag. This is dead code that can probably be removed as a chore task. My focus here was on removing friction for developers reading documentation. ### Description of changes I removed the section in the README of `ecs-patterns` showing how to manually enable this flag. I also updated the default cases in docstrings that referenced the flag. ### Description of how you validated changes Doc change only, no functional changes. I did double check that the defaults described in the docstrings (when the feature flag is enabled) were still accurate. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cdk-lib/aws-ecs-patterns/README.md | 50 ------------------- .../application-load-balanced-service-base.ts | 3 +- ...ion-multiple-target-groups-service-base.ts | 3 +- .../network-load-balanced-service-base.ts | 3 +- ...ork-multiple-target-groups-service-base.ts | 3 +- .../lib/base/queue-processing-service-base.ts | 7 ++- 6 files changed, 7 insertions(+), 62 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/README.md b/packages/aws-cdk-lib/aws-ecs-patterns/README.md index 77f62440f5efa..6dda31ecccfaf 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/README.md +++ b/packages/aws-cdk-lib/aws-ecs-patterns/README.md @@ -921,56 +921,6 @@ const scheduledFargateTask = new ecsPatterns.ScheduledFargateTask(this, 'Schedul }); ``` -### Use the REMOVE_DEFAULT_DESIRED_COUNT feature flag - -The REMOVE_DEFAULT_DESIRED_COUNT feature flag is used to override the default desiredCount that is autogenerated by the CDK. This will set the desiredCount of any service created by any of the following constructs to be undefined. - -* ApplicationLoadBalancedEc2Service -* ApplicationLoadBalancedFargateService -* NetworkLoadBalancedEc2Service -* NetworkLoadBalancedFargateService -* QueueProcessingEc2Service -* QueueProcessingFargateService - -If a desiredCount is not passed in as input to the above constructs, CloudFormation will either create a new service to start up with a desiredCount of 1, or update an existing service to start up with the same desiredCount as prior to the update. - -To enable the feature flag, ensure that the REMOVE_DEFAULT_DESIRED_COUNT flag within an application stack context is set to true, like so: - -```ts -declare const stack: Stack; -stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true); -``` - -The following is an example of an application with the REMOVE_DEFAULT_DESIRED_COUNT feature flag enabled: - -```ts nofixture -import { Construct } from 'constructs'; -import { App, Stack } from 'aws-cdk-lib'; -import * as ec2 from 'aws-cdk-lib/aws-ec2'; -import * as ecs from 'aws-cdk-lib/aws-ecs'; -import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns'; -import * as cxapi from 'aws-cdk-lib/cx-api'; -import * as path from 'path'; - -class MyStack extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - this.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true); - - const vpc = new ec2.Vpc(this, 'VPC', { - maxAzs: 2, - }); - - new ecsPatterns.QueueProcessingFargateService(this, 'QueueProcessingService', { - vpc, - memoryLimitMiB: 512, - image: new ecs.AssetImage(path.join(__dirname, '..', 'sqs-reader')), - }); - } -} -``` - ### Deploy application and metrics sidecar The following is an example of deploying an application along with a metrics sidecar container that utilizes `dockerLabels` for discovery: diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts index 626f35bff4150..8f734fe2fb461 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts @@ -78,8 +78,7 @@ export interface ApplicationLoadBalancedServiceBaseProps { * The desired number of instantiations of the task definition to keep running on the service. * The minimum value is 1 * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1; - * if true, the default is 1 for all new services and uses the existing services desired count + * @default - The default is 1 for all new services and uses the existing service's desired count * when updating an existing service. */ readonly desiredCount?: number; diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts index 219aa491fcdbe..11898cbfb511c 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts @@ -50,8 +50,7 @@ export interface ApplicationMultipleTargetGroupsServiceBaseProps { /** * The desired number of instantiations of the task definition to keep running on the service. * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1; - * if true, the default is 1 for all new services and uses the existing services desired count + * @default - The default is 1 for all new services and uses the existing service's desired count * when updating an existing service. */ readonly desiredCount?: number; diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts index 45f58dd517a12..1939c0fd0684a 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts @@ -66,8 +66,7 @@ export interface NetworkLoadBalancedServiceBaseProps { * The desired number of instantiations of the task definition to keep running on the service. * The minimum value is 1 * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1; - * if true, the default is 1 for all new services and uses the existing services desired count + * @default - The default is 1 for all new services and uses the existing service's desired count * when updating an existing service. */ readonly desiredCount?: number; diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts index 5eeaa3ba9bf82..72d58e12ee2f2 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts @@ -41,8 +41,7 @@ export interface NetworkMultipleTargetGroupsServiceBaseProps { * The desired number of instantiations of the task definition to keep running on the service. * The minimum value is 1 * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1; - * if true, the default is 1 for all new services and uses the existing services desired count + * @default - The default is 1 for all new services and uses the existing service's desired count * when updating an existing service. */ readonly desiredCount?: number; 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 beb207309b217..d61567e55670e 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 @@ -58,8 +58,7 @@ export interface QueueProcessingServiceBaseProps { /** * The desired number of instantiations of the task definition to keep running on the service. * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1; - * if true, the minScalingCapacity is 1 for all new services and uses the existing services desired count + * @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. */ @@ -128,14 +127,14 @@ export interface QueueProcessingServiceBaseProps { /** * Maximum capacity to scale to. * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is (desiredTaskCount * 2); if true, the default is 2. + * @default 2 */ readonly maxScalingCapacity?: number; /** * Minimum capacity to scale to. * - * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is the desiredTaskCount; if true, the default is 1. + * @default 1 */ readonly minScalingCapacity?: number;