"elb name longer than 32"但只有 8 个



我正在尝试使用 AWS cloudformation 创建一个包含 ALB 和 ECS 服务的堆栈,但我在AWS::ECS::Service上得到了一个CREATE_FAILED,这是elb name longer than 32

我不明白为什么 ECS 服务抱怨 ELB 名称,而 ALB 本身处于CREATE_COMPLETE状态......

以下是与我发送到cloudformation的ALB创建相关的JSON:

    "loadBalancer" : {
      "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
      "Properties": {
        "Name": "test-alb",
        "Scheme" : "internal",
        "Subnets" : [
          "subnet-b8217295",
          "subnet-ddaad2b8",
          "subnet-6d71fb51"
        ],
        "LoadBalancerAttributes" : [
          { "Key" : "idle_timeout.timeout_seconds", "Value" : "50" }
        ],
        "SecurityGroups": [
          { "Ref": "InstanceSecurityGroupOpenWeb" },
          { "Ref" : "InstanceSecurityGroupOpenFull" }
        ],
        "Tags" : [
          { "Key" : "key", "Value" : "value" },
          { "Key" : "key2", "Value" : "value2" }
        ]
      }
    }

以下是与 ECS 服务创建相关的 JSON(参考上面定义的 ALB(:

    "EcsService": {
      "Type":"AWS::ECS::Service",
      "Properties":{
        "Cluster":{
          "Ref": "EcsCluster"
        },
        "DesiredCount":"1",
        "DeploymentConfiguration":{
          "MaximumPercent":100,
          "MinimumHealthyPercent":0
        },
        "LoadBalancers": [
          {
            "ContainerName": "test-web",
            "ContainerPort":"80",
            "LoadBalancerName":{
              "Ref": "loadBalancer"
            }
          }
        ],
        "Role":{
          "Ref": "EcsServiceRole"
        },
        "TaskDefinition":{
          "Ref": "runWebServerTaskDefinition"
        }
      }
    }

正如你所看到的,我自己设置了 ALB 的名称,它只有 8 个字符,所以我真的不明白重点,知道吗?

当您执行"Ref"时,它将返回负载均衡器 ARN 而不是负载均衡器名称。 您需要使用 GetAtt 获取负载均衡器名称

{ "Fn::GetAtt" : [ "loadBalancer", "LoadBalancerName" ] }

相关内容

最新更新