From 878b12636420df4960a61499adb529a49d428366 Mon Sep 17 00:00:00 2001 From: Clare Liguori Date: Tue, 13 Nov 2018 10:59:05 -0800 Subject: [PATCH] feat(aws-ecs): expose service and target group on the LoadBalancedFargateService --- .../@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] });