From 323d3572710247df4d6afe40598a701c09fa3ae9 Mon Sep 17 00:00:00 2001 From: Madeline Kusters Date: Thu, 13 May 2021 16:51:03 -0700 Subject: [PATCH 1/2] fix(ecs): Class FargateService has no defaultChild fixes #14665 --- packages/@aws-cdk/aws-ecs/lib/base/base-service.ts | 2 ++ 1 file changed, 2 insertions(+) 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 e51756cf7fa91..8d46952bf1baa 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts @@ -415,6 +415,8 @@ export abstract class BaseService extends Resource if (props.cloudMapOptions) { this.enableCloudMap(props.cloudMapOptions); } + + this.node.defaultChild = this.resource; } /** From 624d6f64c64b77442613fe689a6b109faa89c54f Mon Sep 17 00:00:00 2001 From: Madeline Kusters Date: Fri, 14 May 2021 13:43:49 -0700 Subject: [PATCH 2/2] update unit tests --- packages/@aws-cdk/aws-ecs/test/ec2/ec2-service.test.ts | 4 +++- .../@aws-cdk/aws-ecs/test/fargate/fargate-service.test.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/ec2-service.test.ts b/packages/@aws-cdk/aws-ecs/test/ec2/ec2-service.test.ts index c63c86cce9f65..036604d079c71 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/ec2-service.test.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/ec2-service.test.ts @@ -25,7 +25,7 @@ nodeunitShim({ memoryLimitMiB: 512, }); - new ecs.Ec2Service(stack, 'Ec2Service', { + const service = new ecs.Ec2Service(stack, 'Ec2Service', { cluster, taskDefinition, }); @@ -47,6 +47,8 @@ nodeunitShim({ EnableECSManagedTags: false, })); + test.notEqual(service.node.defaultChild, undefined); + test.done(); }, diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/fargate-service.test.ts b/packages/@aws-cdk/aws-ecs/test/fargate/fargate-service.test.ts index a75ff256cc457..af4b92370726d 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/fargate-service.test.ts +++ b/packages/@aws-cdk/aws-ecs/test/fargate/fargate-service.test.ts @@ -23,7 +23,7 @@ nodeunitShim({ image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), }); - new ecs.FargateService(stack, 'FargateService', { + const service = new ecs.FargateService(stack, 'FargateService', { cluster, taskDefinition, }); @@ -79,6 +79,8 @@ nodeunitShim({ }, })); + test.notEqual(service.node.defaultChild, undefined); + test.done(); },