Skip to content

Commit 7fb639a

Browse files
authoredDec 7, 2021
fix(ecs-patterns): removeDefaultDesiredCount feature flag not expired properly (#17865)
The `@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount` feature flag was expired as part of V2; however, the way the feature flag was accessed meant that the flag wasn't handled the same way all other expired flags were, leading to the incorrect behavior. This fixes the access and evaluation of the flag to match intended behavior, and updates the tests appropriately. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6bb4a46 commit 7fb639a

31 files changed

+50
-73
lines changed
 

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ICluster, LogDriver, PropagatedTagSource, Secret,
66
} from '@aws-cdk/aws-ecs';
77
import { IQueue, Queue } from '@aws-cdk/aws-sqs';
8-
import { CfnOutput, Duration, Stack } from '@aws-cdk/core';
8+
import { CfnOutput, Duration, FeatureFlags, Stack } from '@aws-cdk/core';
99
import * as cxapi from '@aws-cdk/cx-api';
1010
import { Construct } from 'constructs';
1111

@@ -315,7 +315,7 @@ export abstract class QueueProcessingServiceBase extends Construct {
315315
this.desiredCount = props.desiredTaskCount ?? 1;
316316

317317
// Determine the desired task count (minimum) and maximum scaling capacity
318-
if (!this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT)) {
318+
if (!FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT)) {
319319
this.minCapacity = props.minScalingCapacity ?? this.desiredCount;
320320
this.maxCapacity = props.maxScalingCapacity || (2 * this.desiredCount);
321321
} else {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Ec2Service, Ec2TaskDefinition } from '@aws-cdk/aws-ecs';
2+
import { FeatureFlags } from '@aws-cdk/core';
23
import * as cxapi from '@aws-cdk/cx-api';
34
import { Construct } from 'constructs';
45
import { ApplicationLoadBalancedServiceBase, ApplicationLoadBalancedServiceBaseProps } from '../base/application-load-balanced-service-base';
@@ -119,7 +120,7 @@ export class ApplicationLoadBalancedEc2Service extends ApplicationLoadBalancedSe
119120
throw new Error('You must specify one of: taskDefinition or image');
120121
}
121122

122-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
123+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
123124

124125
this.service = new Ec2Service(this, 'Service', {
125126
cluster: this.cluster,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Ec2Service, Ec2TaskDefinition } from '@aws-cdk/aws-ecs';
22
import { ApplicationTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import {
@@ -138,7 +139,7 @@ export class ApplicationMultipleTargetGroupsEc2Service extends ApplicationMultip
138139
}
139140

140141
private createEc2Service(props: ApplicationMultipleTargetGroupsEc2ServiceProps): Ec2Service {
141-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
142+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
142143

143144
return new Ec2Service(this, 'Service', {
144145
cluster: this.cluster,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Ec2Service, Ec2TaskDefinition } from '@aws-cdk/aws-ecs';
2+
import { FeatureFlags } from '@aws-cdk/core';
23
import * as cxapi from '@aws-cdk/cx-api';
34
import { Construct } from 'constructs';
45
import { NetworkLoadBalancedServiceBase, NetworkLoadBalancedServiceBaseProps } from '../base/network-load-balanced-service-base';
@@ -117,7 +118,7 @@ export class NetworkLoadBalancedEc2Service extends NetworkLoadBalancedServiceBas
117118
throw new Error('You must specify one of: taskDefinition or image');
118119
}
119120

120-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
121+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
121122

122123
this.service = new Ec2Service(this, 'Service', {
123124
cluster: this.cluster,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Ec2Service, Ec2TaskDefinition } from '@aws-cdk/aws-ecs';
22
import { NetworkTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import {
@@ -138,7 +139,7 @@ export class NetworkMultipleTargetGroupsEc2Service extends NetworkMultipleTarget
138139
}
139140

140141
private createEc2Service(props: NetworkMultipleTargetGroupsEc2ServiceProps): Ec2Service {
141-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
142+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
142143

143144
return new Ec2Service(this, 'Service', {
144145
cluster: this.cluster,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Ec2Service, Ec2TaskDefinition } from '@aws-cdk/aws-ecs';
2+
import { FeatureFlags } from '@aws-cdk/core';
23
import * as cxapi from '@aws-cdk/cx-api';
34
import { Construct } from 'constructs';
45
import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base';
@@ -108,7 +109,7 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase {
108109
});
109110

110111
// The desiredCount should be removed from the fargate service when the feature flag is removed.
111-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount;
112+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount;
112113

113114
// Create an ECS service with the previously defined Task Definition and configure
114115
// autoscaling based on cpu utilization and number of messages visible in the SQS queue.

‎packages/@aws-cdk/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ISecurityGroup, SubnetSelection } from '@aws-cdk/aws-ec2';
22
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import { ApplicationLoadBalancedServiceBase, ApplicationLoadBalancedServiceBaseProps } from '../base/application-load-balanced-service-base';
@@ -155,7 +156,7 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc
155156
throw new Error('You must specify one of: taskDefinition or image');
156157
}
157158

158-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
159+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
159160

160161
this.service = new FargateService(this, 'Service', {
161162
cluster: this.cluster,

‎packages/@aws-cdk/aws-ecs-patterns/lib/fargate/application-multiple-target-groups-fargate-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
22
import { ApplicationTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import {
@@ -170,7 +171,7 @@ export class ApplicationMultipleTargetGroupsFargateService extends ApplicationMu
170171
}
171172

172173
private createFargateService(props: ApplicationMultipleTargetGroupsFargateServiceProps): FargateService {
173-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
174+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
174175

175176
return new FargateService(this, 'Service', {
176177
cluster: this.cluster,

‎packages/@aws-cdk/aws-ecs-patterns/lib/fargate/network-load-balanced-fargate-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SubnetSelection } from '@aws-cdk/aws-ec2';
22
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import { NetworkLoadBalancedServiceBase, NetworkLoadBalancedServiceBaseProps } from '../base/network-load-balanced-service-base';
@@ -142,7 +143,7 @@ export class NetworkLoadBalancedFargateService extends NetworkLoadBalancedServic
142143
throw new Error('You must specify one of: taskDefinition or image');
143144
}
144145

145-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
146+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
146147

147148
this.service = new FargateService(this, 'Service', {
148149
cluster: this.cluster,

‎packages/@aws-cdk/aws-ecs-patterns/lib/fargate/network-multiple-target-groups-fargate-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
22
import { NetworkTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import {
@@ -170,7 +171,7 @@ export class NetworkMultipleTargetGroupsFargateService extends NetworkMultipleTa
170171
}
171172

172173
private createFargateService(props: NetworkMultipleTargetGroupsFargateServiceProps): FargateService {
173-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
174+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? this.internalDesiredCount : this.desiredCount;
174175

175176
return new FargateService(this, 'Service', {
176177
cluster: this.cluster,

‎packages/@aws-cdk/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as ec2 from '@aws-cdk/aws-ec2';
22
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
3+
import { FeatureFlags } from '@aws-cdk/core';
34
import * as cxapi from '@aws-cdk/cx-api';
45
import { Construct } from 'constructs';
56
import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base';
@@ -130,7 +131,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
130131
});
131132

132133
// The desiredCount should be removed from the fargate service when the feature flag is removed.
133-
const desiredCount = this.node.tryGetContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount;
134+
const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount;
134135

135136
// Create a Fargate service with the previously defined Task Definition and configure
136137
// autoscaling based on cpu utilization and number of messages visible in the SQS queue.

‎packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.expected.json

-1
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,6 @@
11421142
"MaximumPercent": 200,
11431143
"MinimumHealthyPercent": 50
11441144
},
1145-
"DesiredCount": 1,
11461145
"EnableECSManagedTags": false,
11471146
"HealthCheckGracePeriodSeconds": 60,
11481147
"LaunchType": "EC2",

‎packages/@aws-cdk/aws-ecs-patterns/test/ec2/l3s-v2.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('When Application Load Balancer', () => {
4747
expect(stack).toHaveResource('AWS::ElasticLoadBalancingV2::LoadBalancer');
4848

4949
expect(stack).toHaveResource('AWS::ECS::Service', {
50-
DesiredCount: 1,
5150
LaunchType: 'EC2',
5251
});
5352

@@ -929,7 +928,6 @@ describe('When Network Load Balancer', () => {
929928
expect(stack).toHaveResource('AWS::ElasticLoadBalancingV2::LoadBalancer');
930929

931930
expect(stack).toHaveResource('AWS::ECS::Service', {
932-
DesiredCount: 1,
933931
LaunchType: 'EC2',
934932
});
935933

‎packages/@aws-cdk/aws-ecs-patterns/test/ec2/l3s.test.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AsgCapacityProvider } from '@aws-cdk/aws-ecs';
99
import { ApplicationLoadBalancer, ApplicationProtocol, ApplicationProtocolVersion, NetworkLoadBalancer, SslPolicy } from '@aws-cdk/aws-elasticloadbalancingv2';
1010
import { PublicHostedZone } from '@aws-cdk/aws-route53';
1111
import * as cloudmap from '@aws-cdk/aws-servicediscovery';
12+
import { testLegacyBehavior } from '@aws-cdk/cdk-build-tools';
1213
import * as cdk from '@aws-cdk/core';
1314
import * as cxapi from '@aws-cdk/cx-api';
1415
import * as ecsPatterns from '../../lib';
@@ -72,9 +73,9 @@ test('test ECS loadbalanced construct', () => {
7273
});
7374
});
7475

75-
test('ApplicationLoadBalancedEc2Service desiredCount can be undefined when feature flag is set', () => {
76+
testLegacyBehavior('ApplicationLoadBalancedEc2Service desiredCount can be undefined when feature flag is set', cdk.App, (app) => {
7677
// GIVEN
77-
const stack = new cdk.Stack();
78+
const stack = new cdk.Stack(app);
7879
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
7980

8081
const vpc = new ec2.Vpc(stack, 'VPC');
@@ -101,9 +102,9 @@ test('ApplicationLoadBalancedEc2Service desiredCount can be undefined when featu
101102
});
102103
});
103104

104-
test('ApplicationLoadBalancedFargateService desiredCount can be undefined when feature flag is set', () => {
105+
testLegacyBehavior('ApplicationLoadBalancedFargateService desiredCount can be undefined when feature flag is set', cdk.App, (app) => {
105106
// GIVEN
106-
const stack = new cdk.Stack();
107+
const stack = new cdk.Stack(app);
107108
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
108109

109110
const vpc = new ec2.Vpc(stack, 'VPC');
@@ -122,9 +123,9 @@ test('ApplicationLoadBalancedFargateService desiredCount can be undefined when f
122123
});
123124
});
124125

125-
test('NetworkLoadBalancedEc2Service desiredCount can be undefined when feature flag is set', () => {
126+
testLegacyBehavior('NetworkLoadBalancedEc2Service desiredCount can be undefined when feature flag is set', cdk.App, (app) => {
126127
// GIVEN
127-
const stack = new cdk.Stack();
128+
const stack = new cdk.Stack(app);
128129
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
129130

130131
const vpc = new ec2.Vpc(stack, 'VPC');
@@ -151,9 +152,9 @@ test('NetworkLoadBalancedEc2Service desiredCount can be undefined when feature f
151152
});
152153
});
153154

154-
test('NetworkLoadBalancedFargateService desiredCount can be undefined when feature flag is set', () => {
155+
testLegacyBehavior('NetworkLoadBalancedFargateService desiredCount can be undefined when feature flag is set', cdk.App, (app) => {
155156
// GIVEN
156-
const stack = new cdk.Stack();
157+
const stack = new cdk.Stack(app);
157158
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
158159

159160
const vpc = new ec2.Vpc(stack, 'VPC');
@@ -547,7 +548,6 @@ test('test Fargate loadbalanced construct with TLS', () => {
547548
});
548549

549550
expect(stack).toHaveResource('AWS::ECS::Service', {
550-
DesiredCount: 1,
551551
LaunchType: 'FARGATE',
552552
});
553553

@@ -609,7 +609,6 @@ test('test Fargateloadbalanced construct with TLS and default certificate', () =
609609
});
610610

611611
expect(stack).toHaveResource('AWS::ECS::Service', {
612-
DesiredCount: 1,
613612
LaunchType: 'FARGATE',
614613
});
615614

‎packages/@aws-cdk/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as ec2 from '@aws-cdk/aws-ec2';
77
import { AsgCapacityProvider } from '@aws-cdk/aws-ecs';
88
import * as ecs from '@aws-cdk/aws-ecs';
99
import * as sqs from '@aws-cdk/aws-sqs';
10-
import { testDeprecated } from '@aws-cdk/cdk-build-tools';
10+
import { testDeprecated, testLegacyBehavior } from '@aws-cdk/cdk-build-tools';
1111
import * as cdk from '@aws-cdk/core';
1212
import * as cxapi from '@aws-cdk/cx-api';
1313
import * as ecsPatterns from '../../lib';
@@ -34,7 +34,6 @@ test('test ECS queue worker service construct - with only required props', () =>
3434

3535
// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all default properties are set.
3636
expect(stack).toHaveResource('AWS::ECS::Service', {
37-
DesiredCount: 1,
3837
LaunchType: 'EC2',
3938
});
4039

@@ -89,9 +88,9 @@ test('test ECS queue worker service construct - with only required props', () =>
8988
});
9089
});
9190

92-
test('test ECS queue worker service construct - with remove default desiredCount feature flag', () => {
91+
testLegacyBehavior('test ECS queue worker service construct - with remove default desiredCount feature flag', cdk.App, (app) => {
9392
// GIVEN
94-
const stack = new cdk.Stack();
93+
const stack = new cdk.Stack(app);
9594
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
9695

9796
const vpc = new ec2.Vpc(stack, 'VPC');
@@ -143,7 +142,6 @@ test('test ECS queue worker service construct - with optional props for queues',
143142

144143
// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all default properties are set.
145144
expect(stack).toHaveResource('AWS::ECS::Service', {
146-
DesiredCount: 1,
147145
LaunchType: 'EC2',
148146
});
149147

@@ -222,7 +220,6 @@ testDeprecated('test ECS queue worker service construct - with optional props',
222220
image: ecs.ContainerImage.fromRegistry('test'),
223221
command: ['-c', '4', 'amazon.com'],
224222
enableLogging: false,
225-
desiredTaskCount: 2,
226223
environment: {
227224
TEST_ENVIRONMENT_VARIABLE1: 'test environment variable 1 value',
228225
TEST_ENVIRONMENT_VARIABLE2: 'test environment variable 2 value',
@@ -239,7 +236,6 @@ testDeprecated('test ECS queue worker service construct - with optional props',
239236

240237
// THEN - QueueWorker is of EC2 launch type, an SQS queue is created and all optional properties are set.
241238
expect(stack).toHaveResource('AWS::ECS::Service', {
242-
DesiredCount: 2,
243239
DeploymentConfiguration: {
244240
MinimumHealthyPercent: 60,
245241
MaximumPercent: 150,
@@ -300,9 +296,9 @@ testDeprecated('test ECS queue worker service construct - with optional props',
300296
});
301297
});
302298

303-
testDeprecated('can set desiredTaskCount to 0', () => {
299+
testLegacyBehavior('can set desiredTaskCount to 0', cdk.App, (app) => {
304300
// GIVEN
305-
const stack = new cdk.Stack();
301+
const stack = new cdk.Stack(app);
306302
const vpc = new ec2.Vpc(stack, 'VPC');
307303
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
308304
cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', {

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.alb-fargate-service-https.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@
669669
"MaximumPercent": 200,
670670
"MinimumHealthyPercent": 50
671671
},
672-
"DesiredCount": 1,
673672
"EnableECSManagedTags": true,
674673
"HealthCheckGracePeriodSeconds": 60,
675674
"LaunchType": "FARGATE",
@@ -773,4 +772,4 @@
773772
}
774773
}
775774
}
776-
}
775+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@
643643
"MaximumPercent": 200,
644644
"MinimumHealthyPercent": 50
645645
},
646-
"DesiredCount": 1,
647646
"EnableECSManagedTags": false,
648647
"HealthCheckGracePeriodSeconds": 60,
649648
"LaunchType": "FARGATE",
@@ -758,4 +757,4 @@
758757
}
759758
}
760759
}
761-
}
760+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.circuit-breaker-load-balanced-fargate-service.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@
599599
"DeploymentController": {
600600
"Type": "ECS"
601601
},
602-
"DesiredCount": 1,
603602
"EnableECSManagedTags": false,
604603
"HealthCheckGracePeriodSeconds": 60,
605604
"LaunchType": "FARGATE",
@@ -706,4 +705,4 @@
706705
}
707706
}
708707
}
709-
}
708+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.circuit-breaker-queue-processing-fargate-service.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@
601601
"DeploymentController": {
602602
"Type": "ECS"
603603
},
604-
"DesiredCount": 1,
605604
"EnableECSManagedTags": false,
606605
"LaunchType": "FARGATE",
607606
"NetworkConfiguration": {
@@ -846,4 +845,4 @@
846845
}
847846
}
848847
}
849-
}
848+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.executionrole.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@
595595
"MaximumPercent": 200,
596596
"MinimumHealthyPercent": 50
597597
},
598-
"DesiredCount": 1,
599598
"EnableECSManagedTags": false,
600599
"HealthCheckGracePeriodSeconds": 60,
601600
"LaunchType": "FARGATE",
@@ -702,4 +701,4 @@
702701
}
703702
}
704703
}
705-
}
704+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-autocreate.expected.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@
234234
"MaximumPercent": 200,
235235
"MinimumHealthyPercent": 50
236236
},
237-
"DesiredCount": 1,
238237
"EnableECSManagedTags": false,
239238
"HealthCheckGracePeriodSeconds": 60,
240239
"LaunchType": "FARGATE",
@@ -853,7 +852,6 @@
853852
"MaximumPercent": 200,
854853
"MinimumHealthyPercent": 50
855854
},
856-
"DesiredCount": 1,
857855
"EnableECSManagedTags": false,
858856
"HealthCheckGracePeriodSeconds": 60,
859857
"LaunchType": "FARGATE",
@@ -947,4 +945,4 @@
947945
}
948946
}
949947
}
950-
}
948+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-vpconly.expected.json

-2
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@
589589
"MaximumPercent": 200,
590590
"MinimumHealthyPercent": 50
591591
},
592-
"DesiredCount": 1,
593592
"EnableECSManagedTags": false,
594593
"HealthCheckGracePeriodSeconds": 60,
595594
"LaunchType": "FARGATE",
@@ -853,7 +852,6 @@
853852
"MaximumPercent": 200,
854853
"MinimumHealthyPercent": 50
855854
},
856-
"DesiredCount": 1,
857855
"EnableECSManagedTags": false,
858856
"HealthCheckGracePeriodSeconds": 60,
859857
"LaunchType": "FARGATE",

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.expected.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@
592592
"MaximumPercent": 200,
593593
"MinimumHealthyPercent": 50
594594
},
595-
"DesiredCount": 1,
596595
"EnableECSManagedTags": false,
597596
"HealthCheckGracePeriodSeconds": 60,
598597
"LaunchType": "FARGATE",
@@ -853,7 +852,6 @@
853852
"MaximumPercent": 200,
854853
"MinimumHealthyPercent": 50
855854
},
856-
"DesiredCount": 1,
857855
"EnableECSManagedTags": false,
858856
"HealthCheckGracePeriodSeconds": 60,
859857
"LaunchType": "FARGATE",
@@ -947,4 +945,4 @@
947945
}
948946
}
949947
}
950-
}
948+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.multiple-network-load-balanced-fargate-service.expected.json

-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@
597597
"MaximumPercent": 200,
598598
"MinimumHealthyPercent": 50
599599
},
600-
"DesiredCount": 1,
601600
"EnableECSManagedTags": false,
602601
"HealthCheckGracePeriodSeconds": 60,
603602
"LaunchType": "FARGATE",

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-isolated.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,6 @@
903903
"MaximumPercent": 200,
904904
"MinimumHealthyPercent": 50
905905
},
906-
"DesiredCount": 1,
907906
"EnableECSManagedTags": false,
908907
"LaunchType": "FARGATE",
909908
"NetworkConfiguration": {
@@ -1202,4 +1201,4 @@
12021201
}
12031202
}
12041203
}
1205-
}
1204+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-public.expected.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@
753753
"MaximumPercent": 200,
754754
"MinimumHealthyPercent": 50
755755
},
756-
"DesiredCount": 1,
757756
"EnableECSManagedTags": false,
758757
"LaunchType": "FARGATE",
759758
"NetworkConfiguration": {
@@ -1001,4 +1000,4 @@
10011000
}
10021001
}
10031002
}
1004-
}
1003+
}

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service.expected.json

-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@
594594
"MaximumPercent": 200,
595595
"MinimumHealthyPercent": 50
596596
},
597-
"DesiredCount": 1,
598597
"EnableECSManagedTags": false,
599598
"LaunchType": "FARGATE",
600599
"NetworkConfiguration": {

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.special-listener.expected.json

-2
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@
539539
"MaximumPercent": 200,
540540
"MinimumHealthyPercent": 50
541541
},
542-
"DesiredCount": 1,
543542
"EnableECSManagedTags": false,
544543
"HealthCheckGracePeriodSeconds": 60,
545544
"LaunchType": "FARGATE",
@@ -832,7 +831,6 @@
832831
"MaximumPercent": 200,
833832
"MinimumHealthyPercent": 50
834833
},
835-
"DesiredCount": 1,
836834
"EnableECSManagedTags": false,
837835
"HealthCheckGracePeriodSeconds": 60,
838836
"LaunchType": "FARGATE",

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/load-balanced-fargate-service-v2.test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe('When Application Load Balancer', () => {
2424
expect(stack).toHaveResource('AWS::ElasticLoadBalancingV2::LoadBalancer');
2525

2626
expect(stack).toHaveResource('AWS::ECS::Service', {
27-
DesiredCount: 1,
2827
LaunchType: 'FARGATE',
2928
LoadBalancers: [
3029
{
@@ -319,7 +318,6 @@ describe('When Application Load Balancer', () => {
319318
});
320319

321320
expect(stack).toHaveResource('AWS::ECS::Service', {
322-
DesiredCount: 1,
323321
LaunchType: 'FARGATE',
324322
LoadBalancers: [
325323
{
@@ -393,7 +391,6 @@ describe('When Network Load Balancer', () => {
393391
expect(stack).toHaveResource('AWS::ElasticLoadBalancingV2::LoadBalancer');
394392

395393
expect(stack).toHaveResource('AWS::ECS::Service', {
396-
DesiredCount: 1,
397394
LaunchType: 'FARGATE',
398395
LoadBalancers: [
399396
{

‎packages/@aws-cdk/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import * as ec2 from '@aws-cdk/aws-ec2';
66
import { AsgCapacityProvider } from '@aws-cdk/aws-ecs';
77
import * as ecs from '@aws-cdk/aws-ecs';
88
import * as sqs from '@aws-cdk/aws-sqs';
9-
import { testDeprecated } from '@aws-cdk/cdk-build-tools';
9+
import { testDeprecated, testFutureBehavior } from '@aws-cdk/cdk-build-tools';
1010
import * as cdk from '@aws-cdk/core';
1111
import * as cxapi from '@aws-cdk/cx-api';
1212
import * as ecsPatterns from '../../lib';
1313

14+
const flags = { [cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT]: true };
15+
1416
test('test fargate queue worker service construct - with only required props', () => {
1517
// GIVEN
1618
const stack = new cdk.Stack();
@@ -33,7 +35,6 @@ test('test fargate queue worker service construct - with only required props', (
3335

3436
// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all default properties are set.
3537
expect(stack).toHaveResource('AWS::ECS::Service', {
36-
DesiredCount: 1,
3738
LaunchType: 'FARGATE',
3839
});
3940

@@ -110,11 +111,9 @@ test('test fargate queue worker service construct - with only required props', (
110111
});
111112
});
112113

113-
test('test fargate queue worker service construct - with remove default desiredCount feature flag', () => {
114+
testFutureBehavior('test fargate queue worker service construct - with remove default desiredCount feature flag', flags, cdk.App, (app) => {
114115
// GIVEN
115-
const stack = new cdk.Stack();
116-
stack.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
117-
116+
const stack = new cdk.Stack(app);
118117
const vpc = new ec2.Vpc(stack, 'VPC');
119118
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
120119

@@ -157,7 +156,6 @@ test('test fargate queue worker service construct - with optional props for queu
157156

158157
// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all default properties are set.
159158
expect(stack).toHaveResource('AWS::ECS::Service', {
160-
DesiredCount: 1,
161159
LaunchType: 'FARGATE',
162160
});
163161

@@ -353,7 +351,6 @@ testDeprecated('test Fargate queue worker service construct - with optional prop
353351
image: ecs.ContainerImage.fromRegistry('test'),
354352
command: ['-c', '4', 'amazon.com'],
355353
enableLogging: false,
356-
desiredTaskCount: 2,
357354
environment: {
358355
TEST_ENVIRONMENT_VARIABLE1: 'test environment variable 1 value',
359356
TEST_ENVIRONMENT_VARIABLE2: 'test environment variable 2 value',
@@ -370,7 +367,6 @@ testDeprecated('test Fargate queue worker service construct - with optional prop
370367

371368
// THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set.
372369
expect(stack).toHaveResource('AWS::ECS::Service', {
373-
DesiredCount: 2,
374370
DeploymentConfiguration: {
375371
MinimumHealthyPercent: 60,
376372
MaximumPercent: 150,

‎packages/@aws-cdk/aws-elasticloadbalancingv2-targets/test/integ.alb-target.expected.json

-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@
484484
"MaximumPercent": 200,
485485
"MinimumHealthyPercent": 50
486486
},
487-
"DesiredCount": 1,
488487
"EnableECSManagedTags": false,
489488
"HealthCheckGracePeriodSeconds": 60,
490489
"LaunchType": "FARGATE",

0 commit comments

Comments
 (0)
Please sign in to comment.