From e799699623cc3af8f72edb33eff0e23b91d6cea8 Mon Sep 17 00:00:00 2001 From: Clare Liguori Date: Thu, 15 Nov 2018 02:51:10 -0800 Subject: [PATCH] feat(aws-ecs): expose service and target group on the LoadBalancedFargateService (#1175) --- .../@aws-cdk/aws-ecs/lib/load-balanced-fargate-service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service.ts b/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service.ts index 722a016793def..a2cfe02a583f7 100644 --- a/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service.ts @@ -109,6 +109,10 @@ export interface LoadBalancedFargateServiceProps { export class LoadBalancedFargateService extends cdk.Construct { public readonly loadBalancer: elbv2.ApplicationLoadBalancer; + public readonly targetGroup: elbv2.ApplicationTargetGroup; + + public readonly service: FargateService; + constructor(parent: cdk.Construct, id: string, props: LoadBalancedFargateServiceProps) { super(parent, id); @@ -132,6 +136,7 @@ export class LoadBalancedFargateService extends cdk.Construct { taskDefinition, assignPublicIp }); + this.service = service; const internetFacing = props.publicLoadBalancer !== undefined ? props.publicLoadBalancer : true; const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', { @@ -152,7 +157,7 @@ export class LoadBalancedFargateService extends cdk.Construct { listener = lb.addListener('PublicListener', { port: 80, open: true }); } - listener.addTargets('ECS', { + this.targetGroup = listener.addTargets('ECS', { port: 80, targets: [service] });