diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json index 1114a3dc28356..90360e47b3b27 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json @@ -256,7 +256,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "FARGATE", "NetworkConfiguration": { @@ -1044,4 +1043,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-separate-source.lit.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-separate-source.lit.expected.json index 4576cb2ca969c..5b487d51f1219 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-separate-source.lit.expected.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-separate-source.lit.expected.json @@ -1854,7 +1854,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "FARGATE", "NetworkConfiguration": { diff --git a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts index f6f725756167d..56e491f1f98cb 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts @@ -105,7 +105,8 @@ export interface BaseServiceOptions { /** * The desired number of instantiations of the task definition to keep running on the service. * - * @default 1 + * @default - When creating the service, default is 1; when updating the service, default uses + * the current task number. */ readonly desiredCount?: number; diff --git a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts index 33769c3223b08..aa2dd8adbdc43 100644 --- a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts @@ -186,8 +186,7 @@ export class Ec2Service extends BaseService implements IEc2Service { super(scope, id, { ...props, - // If daemon, desiredCount must be undefined and that's what we want. Otherwise, default to 1. - desiredCount: props.daemon || props.desiredCount !== undefined ? props.desiredCount : 1, + desiredCount: props.desiredCount, maxHealthyPercent: props.daemon && props.maxHealthyPercent === undefined ? 100 : props.maxHealthyPercent, minHealthyPercent: props.daemon && props.minHealthyPercent === undefined ? 0 : props.minHealthyPercent, launchType: LaunchType.EC2, diff --git a/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts b/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts index fd0c4bbac64b5..f70ca796ed3f6 100644 --- a/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts @@ -152,7 +152,7 @@ export class FargateService extends BaseService implements IFargateService { super(scope, id, { ...props, - desiredCount: props.desiredCount !== undefined ? props.desiredCount : 1, + desiredCount: props.desiredCount, launchType: LaunchType.FARGATE, propagateTags: propagateTagsFromSource, enableECSManagedTags: props.enableECSManagedTags, diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json index 0c64ae63155b9..176bf38d788a5 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json @@ -867,7 +867,7 @@ }, { "Essential": true, - "Image": "envoyproxy/envoy", + "Image": "envoyproxy/envoy:v1.16.2", "Memory": 256, "Name": "envoy" } @@ -923,7 +923,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "EC2", "NetworkConfiguration": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.ts b/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.ts index 3e91af323831b..1d789d6e6fa2b 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.ts @@ -36,7 +36,8 @@ taskDefinition.addContainer('web', { }); taskDefinition.addContainer('envoy', { - image: ecs.ContainerImage.fromRegistry('envoyproxy/envoy'), + // envoyproxy/envoy:latest tag gone from docker hub: https://github.com/envoyproxy/envoy/issues/6344 + image: ecs.ContainerImage.fromRegistry('envoyproxy/envoy:v1.16.2'), memoryLimitMiB: 256, }); diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json index 62d48e3bced1e..67289e175fa8b 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json @@ -918,7 +918,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "HealthCheckGracePeriodSeconds": 60, "LaunchType": "EC2", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json index c2a555e9c9a71..7ba376073123b 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json @@ -1285,7 +1285,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "EC2", "NetworkConfiguration": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json index bd368de2a0f11..d76ccbf580d80 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json @@ -1133,7 +1133,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "EC2", "NetworkConfiguration": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json index 0d3144db3f8f1..a8f0ceeeebb15 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json @@ -895,7 +895,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "HealthCheckGracePeriodSeconds": 60, "LaunchType": "EC2", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json index a66e3674dd919..2b0faf9e340f1 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json @@ -917,7 +917,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "HealthCheckGracePeriodSeconds": 60, "LaunchType": "EC2", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json index e8638efad5f38..3cc8789e3021a 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json @@ -905,7 +905,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "EC2", "NetworkConfiguration": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json index 7d0f3770d69ce..49e99b166b764 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json @@ -905,7 +905,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "EC2", "SchedulingStrategy": "REPLICA", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json index aaa968ada846f..ae30eab9d2419 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json @@ -1379,7 +1379,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "EC2", "SchedulingStrategy": "REPLICA", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts index a5a2fcdbf63fb..c4b2816234595 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts @@ -41,7 +41,6 @@ export = { MaximumPercent: 200, MinimumHealthyPercent: 50, }, - DesiredCount: 1, LaunchType: LaunchType.EC2, SchedulingStrategy: 'REPLICA', EnableECSManagedTags: false, @@ -452,7 +451,6 @@ export = { MaximumPercent: 200, MinimumHealthyPercent: 50, }, - DesiredCount: 1, SchedulingStrategy: 'REPLICA', EnableECSManagedTags: false, })); @@ -536,33 +534,6 @@ export = { test.done(); }, - 'Output does not contain DesiredCount if daemon mode is set'(test: Test) { - // GIVEN - const stack = new cdk.Stack(); - const vpc = new ec2.Vpc(stack, 'MyVpc', {}); - const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); - cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') }); - const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); - taskDefinition.addContainer('BaseContainer', { - image: ecs.ContainerImage.fromRegistry('test'), - memoryReservationMiB: 10, - }); - - // WHEN - new ecs.Ec2Service(stack, 'Ec2Service', { - cluster, - taskDefinition, - daemon: true, - }); - - // THEN - expect(stack).to(haveResource('AWS::ECS::Service', (service: any) => { - return service.LaunchType === LaunchType.EC2 && service.DesiredCount === undefined; - })); - - test.done(); - }, - 'errors if no container definitions'(test: Test) { // GIVEN const stack = new cdk.Stack(); diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json b/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json index f45347575127a..c6efbdee23f66 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json @@ -569,7 +569,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "FARGATE", "NetworkConfiguration": { diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json index fcc16b80c5545..b0e138464af2a 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json @@ -416,7 +416,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "HealthCheckGracePeriodSeconds": 60, "LaunchType": "FARGATE", diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/integ.nlb-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/fargate/integ.nlb-awsvpc-nw.expected.json index b4298eb8c00c5..ac09689318787 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/integ.nlb-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/fargate/integ.nlb-awsvpc-nw.expected.json @@ -416,7 +416,6 @@ "MaximumPercent": 200, "MinimumHealthyPercent": 50 }, - "DesiredCount": 1, "EnableECSManagedTags": false, "HealthCheckGracePeriodSeconds": 60, "LaunchType": "FARGATE", diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts index 546844c604eac..85ddcd6a07176 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts @@ -40,7 +40,6 @@ export = { MaximumPercent: 200, MinimumHealthyPercent: 50, }, - DesiredCount: 1, LaunchType: LaunchType.FARGATE, EnableECSManagedTags: false, NetworkConfiguration: { @@ -364,7 +363,6 @@ export = { DeploymentController: { Type: 'EXTERNAL', }, - DesiredCount: 1, EnableECSManagedTags: false, NetworkConfiguration: { AwsvpcConfiguration: { @@ -543,7 +541,6 @@ export = { MaximumPercent: 200, MinimumHealthyPercent: 50, }, - DesiredCount: 1, LaunchType: LaunchType.FARGATE, EnableECSManagedTags: false, NetworkConfiguration: { diff --git a/packages/decdk/test/__snapshots__/synth.test.js.snap b/packages/decdk/test/__snapshots__/synth.test.js.snap index 80ee75c27a559..0befd96765754 100644 --- a/packages/decdk/test/__snapshots__/synth.test.js.snap +++ b/packages/decdk/test/__snapshots__/synth.test.js.snap @@ -645,7 +645,6 @@ Object { "MaximumPercent": 200, "MinimumHealthyPercent": 50, }, - "DesiredCount": 1, "EnableECSManagedTags": false, "LaunchType": "FARGATE", "NetworkConfiguration": Object {