Do not use static naming for TargetGroup and LoadBalancers

Using static names for TargetGroup and LoadBalancers would cause
collision when trying to provision the same recipe multiple times with
different stack names.

Prefix target groups and load balancer with the name of the stack so
that multiple stack of the same type can coexist.

Bug: Issue 15234
Change-Id: I0cc6cb237d93b4484f7a837e23682fb29e48b544
diff --git a/dual-primary/cf-cluster.yml b/dual-primary/cf-cluster.yml
index 440c6d7..8c0da20 100644
--- a/dual-primary/cf-cluster.yml
+++ b/dual-primary/cf-cluster.yml
@@ -271,7 +271,7 @@
     Properties:
       Type: network
       Scheme: !Ref PrimariesGerritLoadBalancerScheme
-      Name: 'primary-gerrit-instances'
+      Name: !Sub '${AWS::StackName}-primaries'
       LoadBalancerAttributes:
         - Key: 'load_balancing.cross_zone.enabled'
           Value: true
@@ -289,7 +289,7 @@
       HealthCheckPort: !FindInMap ['Gerrit', 'Port', 'HTTP']
       HealthCheckProtocol: HTTP
       HealthCheckPath: '/config/server/healthcheck~status'
-      Name: 'primaries-gerrit-http'
+      Name: !Sub '${AWS::StackName}-primaries-http'
       TargetGroupAttributes:
         - Key: 'stickiness.enabled'
           Value: true
@@ -320,7 +320,7 @@
       HealthCheckPort: !FindInMap ['Gerrit', 'Port', 'HTTP']
       HealthCheckProtocol: HTTP
       HealthCheckPath: '/config/server/healthcheck~status'
-      Name: 'primaries-gerrit-ssh'
+      Name: !Sub '${AWS::StackName}-primaries-ssh'
 
   PrimariesGerritSSHListener:
     Type: AWS::ElasticLoadBalancingV2::Listener
diff --git a/dual-primary/cf-service-primary.yml b/dual-primary/cf-service-primary.yml
index 8c3384d..70bae78 100644
--- a/dual-primary/cf-service-primary.yml
+++ b/dual-primary/cf-service-primary.yml
@@ -424,7 +424,7 @@
             HealthCheckPort: !FindInMap ['Gerrit', 'Port', 'HTTP']
             HealthCheckProtocol: HTTP
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: !Sub 'gerrit-${GerritInstanceNumber}-primary-http'
+            Name: !Sub '${AWS::StackName}-primary${GerritInstanceNumber}-http'
 
     HTTPListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
@@ -449,7 +449,7 @@
             HealthCheckPort: !FindInMap ['Gerrit', 'Port', 'HTTP']
             HealthCheckProtocol: HTTP
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: !Sub 'gerrit-${GerritInstanceNumber}-primary-ssh'
+            Name: !Sub '${AWS::StackName}-primary${GerritInstanceNumber}-ssh'
 
     SSHListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
diff --git a/dual-primary/cf-service-replica.yml b/dual-primary/cf-service-replica.yml
index df360e7..e63debc 100644
--- a/dual-primary/cf-service-replica.yml
+++ b/dual-primary/cf-service-replica.yml
@@ -457,7 +457,7 @@
             HealthCheckPort: !Ref HTTPHostPort
             HealthCheckProtocol: HTTP
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-replica-http'
+            Name: !Sub '${AWS::StackName}-replica-http'
             TargetGroupAttributes:
               - Key: 'stickiness.enabled'
                 Value: true
@@ -491,7 +491,7 @@
             HealthCheckPort: !Ref HTTPHostPort
             HealthCheckProtocol: HTTP
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-replica-ssh'
+            Name: !Sub '${AWS::StackName}-replica-ssh'
 
     SSHListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
@@ -513,7 +513,7 @@
                   !Join [':', [!Ref 'ClusterStackName', 'VPCId']]
             Port: !Ref GitPort
             Protocol: TCP
-            Name: 'gerrit-replica-git'
+            Name: !Sub '${AWS::StackName}-replica-git'
 
     GitListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
@@ -535,7 +535,7 @@
                   !Join [':', [!Ref 'ClusterStackName', 'VPCId']]
             Port: !Ref GitSSHPort
             Protocol: TCP
-            Name: 'gerrit-replica-git-ssh'
+            Name: !Sub '${AWS::StackName}-replica-gitssh'
 
     GitSSHListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
diff --git a/primary-replica/cf-service-primary.yml b/primary-replica/cf-service-primary.yml
index aed8067..3fe939f 100644
--- a/primary-replica/cf-service-primary.yml
+++ b/primary-replica/cf-service-primary.yml
@@ -363,7 +363,7 @@
             HealthCheckProtocol: HTTP
             HealthCheckPort: !Ref HTTPPort
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-primary-http'
+            Name: !Sub '${ClusterStackName}-primary-http'
 
     HTTPListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
@@ -390,7 +390,7 @@
             HealthCheckProtocol: HTTP
             HealthCheckPort: !Ref HTTPPort
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-primary-ssh'
+            Name: !Sub '${ClusterStackName}-primary-ssh'
 
     SSHListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
diff --git a/primary-replica/cf-service-replica.yml b/primary-replica/cf-service-replica.yml
index bf8be87..4d355f5 100644
--- a/primary-replica/cf-service-replica.yml
+++ b/primary-replica/cf-service-replica.yml
@@ -457,7 +457,7 @@
             HealthCheckPort: !Ref HTTPHostPort
             HealthCheckProtocol: HTTP
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-replica-http'
+            Name: !Sub '${ClusterStackName}-replica-http'
             TargetGroupAttributes:
               - Key: 'stickiness.enabled'
                 Value: true
@@ -491,7 +491,7 @@
             HealthCheckPort: !Ref HTTPHostPort
             HealthCheckProtocol: HTTP
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-replica-ssh'
+            Name: !Sub '${ClusterStackName}-replica-ssh'
 
     SSHListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
diff --git a/single-primary/cf-service.yml b/single-primary/cf-service.yml
index 1bebd2f..c961006 100644
--- a/single-primary/cf-service.yml
+++ b/single-primary/cf-service.yml
@@ -341,7 +341,7 @@
             HealthCheckProtocol: HTTP
             HealthCheckPort: !Ref HTTPPort
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-primary-http'
+            Name: !Sub '${ClusterStackName}-primary-http'
 
     HTTPListener:
         Type: AWS::ElasticLoadBalancingV2::Listener
@@ -368,7 +368,7 @@
             HealthCheckProtocol: HTTP
             HealthCheckPort: !Ref HTTPPort
             HealthCheckPath: '/config/server/healthcheck~status'
-            Name: 'gerrit-primary-ssh'
+            Name: !Sub '${ClusterStackName}-primary-ssh'
 
     SSHListener:
         Type: AWS::ElasticLoadBalancingV2::Listener