Skip to content

Commit 704f596

Browse files
authored
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](#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*
1 parent b19f822 commit 704f596

6 files changed

+7
-62
lines changed

packages/aws-cdk-lib/aws-ecs-patterns/README.md

-50
Original file line numberDiff line numberDiff line change
@@ -921,56 +921,6 @@ const scheduledFargateTask = new ecsPatterns.ScheduledFargateTask(this, 'Schedul
921921
});
922922
```
923923

924-
### Use the REMOVE_DEFAULT_DESIRED_COUNT feature flag
925-
926-
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.
927-
928-
* ApplicationLoadBalancedEc2Service
929-
* ApplicationLoadBalancedFargateService
930-
* NetworkLoadBalancedEc2Service
931-
* NetworkLoadBalancedFargateService
932-
* QueueProcessingEc2Service
933-
* QueueProcessingFargateService
934-
935-
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.
936-
937-
To enable the feature flag, ensure that the REMOVE_DEFAULT_DESIRED_COUNT flag within an application stack context is set to true, like so:
938-
939-
```ts
940-
declare const stack: Stack;
941-
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
942-
```
943-
944-
The following is an example of an application with the REMOVE_DEFAULT_DESIRED_COUNT feature flag enabled:
945-
946-
```ts nofixture
947-
import { Construct } from 'constructs';
948-
import { App, Stack } from 'aws-cdk-lib';
949-
import * as ec2 from 'aws-cdk-lib/aws-ec2';
950-
import * as ecs from 'aws-cdk-lib/aws-ecs';
951-
import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns';
952-
import * as cxapi from 'aws-cdk-lib/cx-api';
953-
import * as path from 'path';
954-
955-
class MyStack extends Stack {
956-
constructor(scope: Construct, id: string) {
957-
super(scope, id);
958-
959-
this.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
960-
961-
const vpc = new ec2.Vpc(this, 'VPC', {
962-
maxAzs: 2,
963-
});
964-
965-
new ecsPatterns.QueueProcessingFargateService(this, 'QueueProcessingService', {
966-
vpc,
967-
memoryLimitMiB: 512,
968-
image: new ecs.AssetImage(path.join(__dirname, '..', 'sqs-reader')),
969-
});
970-
}
971-
}
972-
```
973-
974924
### Deploy application and metrics sidecar
975925

976926
The following is an example of deploying an application along with a metrics sidecar container that utilizes `dockerLabels` for discovery:

packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ export interface ApplicationLoadBalancedServiceBaseProps {
7878
* The desired number of instantiations of the task definition to keep running on the service.
7979
* The minimum value is 1
8080
*
81-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1;
82-
* if true, the default is 1 for all new services and uses the existing services desired count
81+
* @default - The default is 1 for all new services and uses the existing service's desired count
8382
* when updating an existing service.
8483
*/
8584
readonly desiredCount?: number;

packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export interface ApplicationMultipleTargetGroupsServiceBaseProps {
5050
/**
5151
* The desired number of instantiations of the task definition to keep running on the service.
5252
*
53-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1;
54-
* if true, the default is 1 for all new services and uses the existing services desired count
53+
* @default - The default is 1 for all new services and uses the existing service's desired count
5554
* when updating an existing service.
5655
*/
5756
readonly desiredCount?: number;

packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ export interface NetworkLoadBalancedServiceBaseProps {
6666
* The desired number of instantiations of the task definition to keep running on the service.
6767
* The minimum value is 1
6868
*
69-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1;
70-
* if true, the default is 1 for all new services and uses the existing services desired count
69+
* @default - The default is 1 for all new services and uses the existing service's desired count
7170
* when updating an existing service.
7271
*/
7372
readonly desiredCount?: number;

packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export interface NetworkMultipleTargetGroupsServiceBaseProps {
4141
* The desired number of instantiations of the task definition to keep running on the service.
4242
* The minimum value is 1
4343
*
44-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1;
45-
* if true, the default is 1 for all new services and uses the existing services desired count
44+
* @default - The default is 1 for all new services and uses the existing service's desired count
4645
* when updating an existing service.
4746
*/
4847
readonly desiredCount?: number;

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ export interface QueueProcessingServiceBaseProps {
5858
/**
5959
* The desired number of instantiations of the task definition to keep running on the service.
6060
*
61-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1;
62-
* if true, the minScalingCapacity is 1 for all new services and uses the existing services desired count
61+
* @default - The minScalingCapacity is 1 for all new services and uses the existing services desired count
6362
* when updating an existing service.
6463
* @deprecated - Use `minScalingCapacity` or a literal object instead.
6564
*/
@@ -128,14 +127,14 @@ export interface QueueProcessingServiceBaseProps {
128127
/**
129128
* Maximum capacity to scale to.
130129
*
131-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is (desiredTaskCount * 2); if true, the default is 2.
130+
* @default 2
132131
*/
133132
readonly maxScalingCapacity?: number;
134133

135134
/**
136135
* Minimum capacity to scale to.
137136
*
138-
* @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is the desiredTaskCount; if true, the default is 1.
137+
* @default 1
139138
*/
140139
readonly minScalingCapacity?: number;
141140

0 commit comments

Comments
 (0)