代码之家  ›  专栏  ›  技术社区  ›  pkaramol

AWS ECS:ECSService CloudFormation资源定义中的LoadBalancers属性错误

  •  2
  • pkaramol  · 技术社区  · 7 年前

      MyUIService:
        Type: AWS::ECS::Service
        Properties:
          Cluster: !ImportValue MyClusterName
          DesiredCount: 1
          LaunchType: EC2
          LoadBalancers:
            - !ImportValue ALBDemo
          Role: !Ref MyServiceRole
          ServiceName: my-ui-service
          ServiceRegistries:
           - arn:aws:servicediscovery:eu-west-1:2398942890842:service/srv-ohc098mdj55yesez7
          TaskDefinition: !ImportValue MyTaskArn
    

    LoadBalancers属性的值必须是对象列表

    但是 我是 定义一个列表(尽管只有一个元素)。

    该列表包含ALB的arn导出。

    确切的语法是什么?

    编辑 :这是相关的 documentation 这似乎与错误不一致:

    负载平衡器

    要与群集关联的负载平衡器对象的列表。如果指定Role属性,则必须将LoadBalancer指定为 好。有关可以使用的负载平衡器数量的信息 容器服务开发人员指南。 必需:有条件 类型:Amazon弹性容器服务loadbalancer列表

    1 回复  |  直到 7 年前
        1
  •  3
  •   Victor Wong    7 年前

    我看到你复制了同一个模板 AWS templates .

    MyUIService:
      Type: AWS::ECS::Service
      Properties:
        Cluster: !ImportValue MyClusterName
        DesiredCount: 1
        LaunchType: EC2
        LoadBalancers:
          - ContainerName: simple-app
            ContainerPort: '80'
            TargetGroupArn: !Ref 'ECSTG'
        Role: !Ref MyServiceRole
        ServiceName: my-ui-service
        ServiceRegistries:
         - arn:aws:servicediscovery:eu-west-1:2398942890842:service/srv-ohc098mdj55yesez7
        TaskDefinition: !ImportValue MyTaskArn
    

    请注意,loadbalancer实际上并不直接引用负载平衡器。它引用目标组。这是相当奇怪的命名,但如果你通过网络控制台,你会得出相同的结论。

    AWS documentation :

    ContainerName
    The name of a container to use with the load balancer.
    
    Required: Yes
    
    Type: String
    
    
    ContainerPort
    The port number on the container to direct load balancer traffic to. Your container instances must allow ingress traffic on this port.
    
    Required: Yes
    
    Type: Integer
    

    这些是 但是你永远不能通过导入负载平衡器来获得它们。