当前位置:  开发笔记 > 前端 > 正文

创建堆栈中的Cloudformation错误:“ ELB无法连接到同一可用区中的多个子网”

如何解决《创建堆栈中的Cloudformation错误:“ELB无法连接到同一可用区中的多个子网”》经验,为你挑选了1个好方法。

我尝试使用Cloudformation json模板构建基础结构。当我在两个所需的可用区域中添加两个Subnets和SubnetRouteTableAssociation时。但是创建过程无法创建错误的负载均衡器:

CREATE_FAILED AWS :: ElasticLoadBalancing :: LoadBalancer Rest ELB无法连接到同一可用区中的多个子网。

这是可用区的参数:

"AZs" : {
            "Description" : "The list of AvailabilityZones.",
            "Type" : "CommaDelimitedList",
            "Default" : "us-east-1a,us-east-1c"
        }

这是可用性区域中的子网资源,SubnetRouteTableAssociation和Rest的ElasticLoadBalancing:

"PublicSubnet1a" : {
      "Type" : "AWS::EC2::Subnet",
      "Properties" : {
        "VpcId" : { "Ref" : "VPC" },
        "CidrBlock" : "10.0.0.0/24",
        "AvailabilityZone": {
          "Fn::Select": ["1", { "Ref": "AZs" }]
        },
        "Tags" : [
          {"Key": "Name", "Value": {"Fn::Join": ["", ["Offering-", {"Ref": "Env"}, {"Ref": "EnvNum"}, "-VPC"]]}},
          {"Key" : "Network", "Value" : "Public" }
        ]
      }
    },
     "PublicSubnet1c" : {
      "Type": "AWS::EC2::Subnet",
      "Properties": {
        "VpcId": { "Ref" : "VPC" },
        "CidrBlock": "10.0.1.0/24",
        "AvailabilityZone": {
          "Fn::Select": ["1", { "Ref": "AZs" }]
        },
        "Tags" : [
          {"Key": "Name", "Value": {"Fn::Join": ["", ["Offering-", {"Ref": "Env"}, {"Ref": "EnvNum"}, "-VPC"]]}},
          {"Key" : "Network", "Value" : "Public" }
        ]
      }
    },
"PublicSubnet1aRouteTableAssociation" : {
      "Type" : "AWS::EC2::SubnetRouteTableAssociation",
      "Properties" : {
        "SubnetId" : { "Ref" : "PublicSubnet1a" },
        "RouteTableId" : { "Ref" : "PublicRouteTable" }
      }
    },
    "PublicSubnet1cRouteTableAssociation" : {
      "Type" : "AWS::EC2::SubnetRouteTableAssociation",
      "Properties" : {
        "SubnetId" : { "Ref" : "PublicSubnet1c" },
        "RouteTableId" : { "Ref" : "PublicRouteTable" }
      }
    },
"RestELB" : {
        "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
        "DependsOn": "AttachGateway",
        "Properties": {
            "LoadBalancerName": {"Fn::Join": ["",["Rest-ELB-", {"Ref": "VPC"}]]},
            "CrossZone" : "true",
            "Subnets": [{ "Ref": "PublicSubnet1a" },{ "Ref": "PublicSubnet1c" }],
            "Listeners" : [
                {"LoadBalancerPort" : "80", "InstancePort" : "80","Protocol" : "HTTP"},
                {"LoadBalancerPort" : "6060", "InstancePort" : "6060","Protocol" : "HTTP"}
            ],
            "HealthCheck" : {
              "Target" : "HTTP:80/",
              "HealthyThreshold" : "3",
              "UnhealthyThreshold" : "5",
              "Interval" : "90",
              "Timeout" : "60"
            }
        }
    }

我做错了什么?

谢谢!



1> Molecular Ma..:
"PublicSubnet1a" : {
    ...
    "AvailabilityZone": {
      "Fn::Select": ["1", { "Ref": "AZs" }] // <---- selects index 1 from AZs list
    },
    ...
"PublicSubnet1c" : {
    ...
    "AvailabilityZone": {
      "Fn::Select": ["1", { "Ref": "AZs" }] // <---- selects the same index 1 from AZs list
    },

您的两个子网都从AZ列表中选择了相同的索引(请参见“ FN :: select”语句)。更改select语句PublicSubnet1a

"Fn::Select": ["0", { "Ref": "AZs" }]

推荐阅读
jerry613
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有