primary-replica/cf-service-primary.yml [200:250]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  ShouldEnableXRay: !Equals [!Ref EnableXray, true]

Resources:
    Service:
        Type: AWS::ECS::Service
        DependsOn:
          - HTTPListener
          - SSHListener
        Properties:
            Cluster:
              Fn::ImportValue:
                  !Join [':', [!Ref 'ClusterStackName', 'ClusterName']]
            DesiredCount: !Ref DesiredCount
            TaskDefinition: !Ref TaskDefinition
            LoadBalancers:
                - ContainerName: !Ref GerritServiceName
                  ContainerPort: !Ref HTTPPort
                  TargetGroupArn: !Ref HTTPTargetGroup
                - ContainerName: !Ref GerritServiceName
                  ContainerPort: !Ref SSHPort
                  TargetGroupArn: !Ref SSHTargetGroup

    TaskDefinition:
        Type: AWS::ECS::TaskDefinition
        Properties:
            Family: !Join ['', [!Ref GerritServiceName, TaskDefinition]]
            TaskRoleArn: !GetAtt ECSTaskExecutionRoleStack.Outputs.TaskExecutionRoleRef
            ExecutionRoleArn: !GetAtt ECSTaskExecutionRoleStack.Outputs.TaskExecutionRoleRef
            NetworkMode: bridge
            PlacementConstraints:
              - Expression: !Sub 'attribute:target_group == primary'
                Type: "memberOf"
            ContainerDefinitions:
                - Name: !Ref GerritServiceName
                  Essential: true
                  Image: !Sub '${DockerRegistryUrl}/${DockerImage}'
                  Environment:
                    - Name: XRAY_ENABLED
                      Value: !Ref EnableXray
                    - Name: AWS_XRAY_TRACING_NAME
                      Value: !Ref InstanceId
                    - Name: AWS_XRAY_DAEMON_ADDRESS
                      Value: !Join [':', [!FindInMap ['XRay', 'Info', 'ContainerName'], !FindInMap ['XRay', 'Info', 'Port']]]
                    - Name: CANONICAL_WEB_URL
                      Value: !Sub 'https://${HttpSubdomain}.${HostedZoneName}'
                    - Name: SSHD_ADVERTISED_ADDRESS
                      Value: !Sub '${SshSubdomain}.${HostedZoneName}:${SSHPort}'
                    - Name: HTTPD_LISTEN_URL
                      Value: !Sub 'proxy-https://*:${HTTPPort}/'
                    - Name: AWS_REGION
                      Value: !Ref AWS::Region
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



single-primary/cf-service.yml [187:236]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  ShouldEnableXRay: !Equals [!Ref EnableXray, true]
Resources:
    Service:
        Type: AWS::ECS::Service
        DependsOn:
          - HTTPListener
          - SSHListener
        Properties:
            Cluster:
              Fn::ImportValue:
                  !Join [':', [!Ref 'ClusterStackName', 'ClusterName']]
            DesiredCount: !Ref DesiredCount
            TaskDefinition: !Ref TaskDefinition
            LoadBalancers:
                - ContainerName: !Ref GerritServiceName
                  ContainerPort: !Ref HTTPPort
                  TargetGroupArn: !Ref HTTPTargetGroup
                - ContainerName: !Ref GerritServiceName
                  ContainerPort: !Ref SSHPort
                  TargetGroupArn: !Ref SSHTargetGroup

    TaskDefinition:
        Type: AWS::ECS::TaskDefinition
        Properties:
            Family: !Join ['', [!Ref GerritServiceName, TaskDefinition]]
            TaskRoleArn: !GetAtt ECSTaskExecutionRoleStack.Outputs.TaskExecutionRoleRef
            ExecutionRoleArn: !GetAtt ECSTaskExecutionRoleStack.Outputs.TaskExecutionRoleRef
            NetworkMode: bridge
            PlacementConstraints:
              - Expression: !Sub 'attribute:target_group == primary'
                Type: "memberOf"
            ContainerDefinitions:
                - Name: !Ref GerritServiceName
                  Essential: true
                  Image: !Sub '${DockerRegistryUrl}/${DockerImage}'
                  Environment:
                    - Name: XRAY_ENABLED
                      Value: !Ref EnableXray
                    - Name: AWS_XRAY_TRACING_NAME
                      Value: !Ref InstanceId
                    - Name: AWS_XRAY_DAEMON_ADDRESS
                      Value: !Join [':', [!FindInMap ['XRay', 'Info', 'ContainerName'], !FindInMap ['XRay', 'Info', 'Port']]]
                    - Name: CANONICAL_WEB_URL
                      Value: !Sub 'https://${HttpSubdomain}.${HostedZoneName}'
                    - Name: SSHD_ADVERTISED_ADDRESS
                      Value: !Sub '${SshSubdomain}.${HostedZoneName}:${SSHPort}'
                    - Name: HTTPD_LISTEN_URL
                      Value: !Sub 'proxy-https://*:${HTTPPort}/'
                    - Name: AWS_REGION
                      Value: !Ref AWS::Region
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



