我尝试使用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" } } }
我做错了什么?
谢谢!
"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" }]