From 9c0fecf9a5cc26416e814ae4754729b54c827b9d Mon Sep 17 00:00:00 2001 From: Luca Pizzini Date: Tue, 26 Dec 2023 20:39:24 +0100 Subject: [PATCH] fix(ecs-patterns): `ApplicationMultipleTargetGroupsEc2Service` ignores load balancer name (#28394) Fixes by adding the `loadBalancerName` property to the generated `ApplicationLoadBalancer`. Closes #23535. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...eg-multiple-alb-healthchecks.template.json | 2 + .../tree.json | 3 + ...s-ecs-integ-alb-idle-timeout.template.json | 60 ++++++++++--------- .../manifest.json | 18 +++--- .../tree.json | 22 +++---- ...-load-balanced-ecs-service-idle-timeout.ts | 2 +- .../aws-ecs-integ-multiple-alb.template.json | 1 + ...teg-fargate-multi-alb-health.template.json | 2 + .../tree.json | 2 + ...ion-multiple-target-groups-service-base.ts | 1 + .../aws-ecs-patterns/test/ec2/l3s-v2.test.ts | 4 ++ 11 files changed, 67 insertions(+), 50 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb-healthchecks.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb-healthchecks.template.json index 56028c9d6a02e..a9fee4a8c1890 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb-healthchecks.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb-healthchecks.template.json @@ -661,6 +661,7 @@ "myServicelb1FA8CBE12": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "lb1", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", @@ -772,6 +773,7 @@ "myServicelb2C84C7BCB": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "lb2", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/tree.json index cfee0a0eedaeb..3d4b9898d7324 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.healthchecks-multiple-application-load-balanced-ecs-service.js.snapshot/tree.json @@ -1457,6 +1457,7 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "aws:cdk:cloudformation:props": { + "name": "lb1", "loadBalancerAttributes": [ { "key": "deletion_protection.enabled", @@ -1677,8 +1678,10 @@ "id": "Resource", "path": "aws-ecs-integ-multiple-alb-healthchecks/myService/lb2/Resource", "attributes": { + "name": "lb2", "aws:cdk:cloudformation:type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "aws:cdk:cloudformation:props": { + "name": "lb2", "loadBalancerAttributes": [ { "key": "deletion_protection.enabled", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json index 4ccc8a3069f81..6b1123cd0cd7a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json @@ -422,7 +422,7 @@ } } }, - "ClusterDefaultAutoScalingGroupInstanceSecurityGroupfromawsecsintegalbidletimeoutmyServicelbSecurityGroupDA02006B327686553535B38FF6": { + "ClusterDefaultAutoScalingGroupInstanceSecurityGroupfromawsecsintegalbidletimeoutmyServicelb1SecurityGroup378D68EF32768655356B9A3535": { "Type": "AWS::EC2::SecurityGroupIngress", "Properties": { "IpProtocol": "tcp", @@ -436,7 +436,7 @@ }, "SourceSecurityGroupId": { "Fn::GetAtt": [ - "myServicelbSecurityGroup97C897CA", + "myServicelb1SecurityGroup342C51EA", "GroupId" ] }, @@ -896,9 +896,10 @@ "ClusterDefaultAutoScalingGroupLifecycleHookDrainHookRole70201663" ] }, - "myServicelb360A9ADD": { + "myServicelb1FA8CBE12": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "lb1", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", @@ -913,7 +914,7 @@ "SecurityGroups": [ { "Fn::GetAtt": [ - "myServicelbSecurityGroup97C897CA", + "myServicelb1SecurityGroup342C51EA", "GroupId" ] } @@ -935,10 +936,10 @@ "VpcPublicSubnet2RouteTableAssociationDD5762D8" ] }, - "myServicelbSecurityGroup97C897CA": { + "myServicelb1SecurityGroup342C51EA": { "Type": "AWS::EC2::SecurityGroup", "Properties": { - "GroupDescription": "Automatically created Security Group for ELB awsecsintegalbidletimeoutmyServicelb9997A785", + "GroupDescription": "Automatically created Security Group for ELB awsecsintegalbidletimeoutmyServicelb1D1305870", "SecurityGroupIngress": [ { "CidrIp": "0.0.0.0/0", @@ -953,12 +954,12 @@ } } }, - "myServicelbSecurityGrouptoawsecsintegalbidletimeoutClusterDefaultAutoScalingGroupInstanceSecurityGroup9C8FC9DE3276865535B06FECE0": { + "myServicelb1SecurityGrouptoawsecsintegalbidletimeoutClusterDefaultAutoScalingGroupInstanceSecurityGroup9C8FC9DE327686553594C8842C": { "Type": "AWS::EC2::SecurityGroupEgress", "Properties": { "GroupId": { "Fn::GetAtt": [ - "myServicelbSecurityGroup97C897CA", + "myServicelb1SecurityGroup342C51EA", "GroupId" ] }, @@ -974,19 +975,19 @@ "ToPort": 65535 } }, - "myServicelblistener1D7944F2": { + "myServicelb1listener94ADDDDF": { "Type": "AWS::ElasticLoadBalancingV2::Listener", "Properties": { "DefaultActions": [ { "TargetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4" + "Ref": "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5" }, "Type": "forward" } ], "LoadBalancerArn": { - "Ref": "myServicelb360A9ADD" + "Ref": "myServicelb1FA8CBE12" }, "Certificates": [ { @@ -998,7 +999,7 @@ "SslPolicy": "ELBSecurityPolicy-TLS-1-2-Ext-2018-06" } }, - "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4": { + "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5": { "Type": "AWS::ElasticLoadBalancingV2::TargetGroup", "Properties": { "Port": 80, @@ -1015,7 +1016,7 @@ } } }, - "myServicelblistenerECSTargetGroupweb90Group4AA47881": { + "myServicelb1listenerECSTargetGroupweb90Group392113A5": { "Type": "AWS::ElasticLoadBalancingV2::TargetGroup", "Properties": { "Port": 80, @@ -1032,13 +1033,13 @@ } } }, - "myServicelblistenerECSTargetGroupweb90Rule68215E8D": { + "myServicelb1listenerECSTargetGroupweb90Rule88D36BAE": { "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", "Properties": { "Actions": [ { "TargetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb90Group4AA47881" + "Ref": "myServicelb1listenerECSTargetGroupweb90Group392113A5" }, "Type": "forward" } @@ -1055,11 +1056,11 @@ ], "Priority": 10, "ListenerArn": { - "Ref": "myServicelblistener1D7944F2" + "Ref": "myServicelb1listener94ADDDDF" } } }, - "myServiceDNSlb1E167074": { + "myServiceDNSlb1447CEC86": { "Type": "AWS::Route53::RecordSet", "Properties": { "Name": "api.example.com.", @@ -1072,7 +1073,7 @@ "dualstack.", { "Fn::GetAtt": [ - "myServicelb360A9ADD", + "myServicelb1FA8CBE12", "DNSName" ] } @@ -1081,7 +1082,7 @@ }, "HostedZoneId": { "Fn::GetAtt": [ - "myServicelb360A9ADD", + "myServicelb1FA8CBE12", "CanonicalHostedZoneID" ] } @@ -1094,6 +1095,7 @@ "myServicelb2C84C7BCB": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "lb2", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", @@ -1467,14 +1469,14 @@ "ContainerName": "web", "ContainerPort": 80, "TargetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4" + "Ref": "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5" } }, { "ContainerName": "web", "ContainerPort": 90, "TargetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb90Group4AA47881" + "Ref": "myServicelb1listenerECSTargetGroupweb90Group392113A5" } }, { @@ -1498,10 +1500,10 @@ } }, "DependsOn": [ - "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4", - "myServicelblistenerECSTargetGroupweb90Group4AA47881", - "myServicelblistenerECSTargetGroupweb90Rule68215E8D", - "myServicelblistener1D7944F2", + "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5", + "myServicelb1listenerECSTargetGroupweb90Group392113A5", + "myServicelb1listenerECSTargetGroupweb90Rule88D36BAE", + "myServicelb1listener94ADDDDF", "myServicelb2listener2ECSTargetGroupweb443Group8FAB1268", "myServicelb2listener2ECSTargetGroupweb80Group0590BDE6", "myServicelb2listener2ECSTargetGroupweb80Rule2490715C", @@ -1523,22 +1525,22 @@ } }, "Outputs": { - "myServiceLoadBalancerDNSlbDE816AD2": { + "myServiceLoadBalancerDNSlb1341EE21A": { "Value": { "Fn::GetAtt": [ - "myServicelb360A9ADD", + "myServicelb1FA8CBE12", "DNSName" ] } }, - "myServiceServiceURLlbhttps4348F098": { + "myServiceServiceURLlb1https6C9C5530": { "Value": { "Fn::Join": [ "", [ "https://", { - "Ref": "myServiceDNSlb1E167074" + "Ref": "myServiceDNSlb1447CEC86" } ] ] diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/manifest.json index c52be66e9890a..d68689ad7d0af 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/manifest.json @@ -192,7 +192,7 @@ "/aws-ecs-integ-alb-idle-timeout/Cluster/DefaultAutoScalingGroup/InstanceSecurityGroup/from awsecsintegalbidletimeoutmyServicelbSecurityGroupDA02006B:32768-65535": [ { "type": "aws:cdk:logicalId", - "data": "ClusterDefaultAutoScalingGroupInstanceSecurityGroupfromawsecsintegalbidletimeoutmyServicelbSecurityGroupDA02006B327686553535B38FF6" + "data": "ClusterDefaultAutoScalingGroupInstanceSecurityGroupfromawsecsintegalbidletimeoutmyServicelb1SecurityGroup378D68EF32768655356B9A3535" } ], "/aws-ecs-integ-alb-idle-timeout/Cluster/DefaultAutoScalingGroup/InstanceSecurityGroup/from awsecsintegalbidletimeoutmyServicelb2SecurityGroupE659E2B0:32768-65535": [ @@ -294,49 +294,49 @@ "/aws-ecs-integ-alb-idle-timeout/myService/lb/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServicelb360A9ADD" + "data": "myServicelb1FA8CBE12" } ], "/aws-ecs-integ-alb-idle-timeout/myService/lb/SecurityGroup/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServicelbSecurityGroup97C897CA" + "data": "myServicelb1SecurityGroup342C51EA" } ], "/aws-ecs-integ-alb-idle-timeout/myService/lb/SecurityGroup/to awsecsintegalbidletimeoutClusterDefaultAutoScalingGroupInstanceSecurityGroup9C8FC9DE:32768-65535": [ { "type": "aws:cdk:logicalId", - "data": "myServicelbSecurityGrouptoawsecsintegalbidletimeoutClusterDefaultAutoScalingGroupInstanceSecurityGroup9C8FC9DE3276865535B06FECE0" + "data": "myServicelb1SecurityGrouptoawsecsintegalbidletimeoutClusterDefaultAutoScalingGroupInstanceSecurityGroup9C8FC9DE327686553594C8842C" } ], "/aws-ecs-integ-alb-idle-timeout/myService/lb/listener/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServicelblistener1D7944F2" + "data": "myServicelb1listener94ADDDDF" } ], "/aws-ecs-integ-alb-idle-timeout/myService/lb/listener/ECSTargetGroupweb80Group/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4" + "data": "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5" } ], "/aws-ecs-integ-alb-idle-timeout/myService/lb/listener/ECSTargetGroupweb90Group/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServicelblistenerECSTargetGroupweb90Group4AA47881" + "data": "myServicelb1listenerECSTargetGroupweb90Group392113A5" } ], "/aws-ecs-integ-alb-idle-timeout/myService/lb/listener/ECSTargetGroupweb90Rule/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServicelblistenerECSTargetGroupweb90Rule68215E8D" + "data": "myServicelb1listenerECSTargetGroupweb90Rule88D36BAE" } ], "/aws-ecs-integ-alb-idle-timeout/myService/DNSlb/Resource": [ { "type": "aws:cdk:logicalId", - "data": "myServiceDNSlb1E167074" + "data": "myServiceDNSlb1447CEC86" } ], "/aws-ecs-integ-alb-idle-timeout/myService/LoadBalancerDNSlb": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json index 4111a3f071c78..46383ce272fd2 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json @@ -746,7 +746,7 @@ }, "sourceSecurityGroupId": { "Fn::GetAtt": [ - "myServicelbSecurityGroup97C897CA", + "myServicelb1SecurityGroup342C51EA", "GroupId" ] }, @@ -1523,7 +1523,7 @@ "securityGroups": [ { "Fn::GetAtt": [ - "myServicelbSecurityGroup97C897CA", + "myServicelb1SecurityGroup342C51EA", "GroupId" ] } @@ -1582,7 +1582,7 @@ "aws:cdk:cloudformation:props": { "groupId": { "Fn::GetAtt": [ - "myServicelbSecurityGroup97C897CA", + "myServicelb1SecurityGroup342C51EA", "GroupId" ] }, @@ -1623,12 +1623,12 @@ { "type": "forward", "targetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4" + "Ref": "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5" } } ], "loadBalancerArn": { - "Ref": "myServicelb360A9ADD" + "Ref": "myServicelb1FA8CBE12" }, "certificates": [ { @@ -1729,7 +1729,7 @@ { "type": "forward", "targetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb90Group4AA47881" + "Ref": "myServicelb1listenerECSTargetGroupweb90Group392113A5" } } ], @@ -1745,7 +1745,7 @@ ], "priority": 10, "listenerArn": { - "Ref": "myServicelblistener1D7944F2" + "Ref": "myServicelb1listener94ADDDDF" } } }, @@ -1787,7 +1787,7 @@ "aliasTarget": { "hostedZoneId": { "Fn::GetAtt": [ - "myServicelb360A9ADD", + "myServicelb1FA8CBE12", "CanonicalHostedZoneID" ] }, @@ -1798,7 +1798,7 @@ "dualstack.", { "Fn::GetAtt": [ - "myServicelb360A9ADD", + "myServicelb1FA8CBE12", "DNSName" ] } @@ -2496,14 +2496,14 @@ "loadBalancers": [ { "targetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb80Group4ADFE4C4" + "Ref": "myServicelb1listenerECSTargetGroupweb80Group6EDAD1E5" }, "containerName": "web", "containerPort": 80 }, { "targetGroupArn": { - "Ref": "myServicelblistenerECSTargetGroupweb90Group4AA47881" + "Ref": "myServicelb1listenerECSTargetGroupweb90Group392113A5" }, "containerName": "web", "containerPort": 90 diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts index fe8b376d154a3..4b45915b50265 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts @@ -26,7 +26,7 @@ new ApplicationMultipleTargetGroupsEc2Service(stack, 'myService', { enableExecuteCommand: true, loadBalancers: [ { - name: 'lb', + name: 'lb1', idleTimeout: Duration.seconds(5), domainName: 'api.example.com', domainZone: zone, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb.template.json index c75dcc26aaacf..03c4e9329b17d 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.js.snapshot/aws-ecs-integ-multiple-alb.template.json @@ -872,6 +872,7 @@ "myServiceLB168895E1": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "LB", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/aws-ecs-integ-fargate-multi-alb-health.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/aws-ecs-integ-fargate-multi-alb-health.template.json index fd6b6f2df0fc2..547dd661aa10f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/aws-ecs-integ-fargate-multi-alb-health.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/aws-ecs-integ-fargate-multi-alb-health.template.json @@ -397,6 +397,7 @@ "myServicelb1FA8CBE12": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "lb1", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", @@ -514,6 +515,7 @@ "myServicelb2C84C7BCB": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "Properties": { + "Name": "lb2", "LoadBalancerAttributes": [ { "Key": "deletion_protection.enabled", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/tree.json index f9f94e1a4eb9b..30f4cc5e2b6fc 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.healthchecks-multiple-application-load-balanced-fargate-service.js.snapshot/tree.json @@ -687,6 +687,7 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "aws:cdk:cloudformation:props": { + "name": "lb1", "loadBalancerAttributes": [ { "key": "deletion_protection.enabled", @@ -894,6 +895,7 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::ElasticLoadBalancingV2::LoadBalancer", "aws:cdk:cloudformation:props": { + "name": "lb2", "loadBalancerAttributes": [ { "key": "deletion_protection.enabled", diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts index 9ac8750f6ff6c..219aa491fcdbe 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts @@ -600,6 +600,7 @@ export abstract class ApplicationMultipleTargetGroupsServiceBase extends Constru vpc: this.cluster.vpc, internetFacing, idleTimeout: idleTimeout, + loadBalancerName: name, }; return new ApplicationLoadBalancer(this, name, lbProps); diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s-v2.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s-v2.test.ts index 35d4ba589927b..325101a7ee30b 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s-v2.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s-v2.test.ts @@ -275,6 +275,10 @@ describe('When Application Load Balancer', () => { }], SslPolicy: SslPolicy.TLS12_EXT, }); + + Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::LoadBalancer', { + Name: 'lb', + }); }); test('able to pass pre-defined task definition', () => {