AWS Autoscale 负载均衡与 Cloudformation
AWS Autoscale Load Balancing with Cloudformation
我正在尝试创建一个 EC2 实例,它将使用自动缩放,附加到负载均衡器。
很遗憾,我遇到了错误
The availability zones of the specified subnets and the AutoScalingGroup do not match
但是,这是我当前的 Cloudformation 脚本:
"ApiAutoScaling" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"VPCZoneIdentifier" : [ "subnet-5ff05206", "subnet-b1109fc6", "subnet-948ce5f1" ],
"InstanceId" : {
"Ref" : "ApiEC2"
},
"MaxSize" : 3,
"MinSize" : 1,
"LoadBalancerNames" : [ "Api" ]
}
},
"ApiLoadBalancer" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"LoadBalancerName" : "Api",
"Listeners" : [
{
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "80",
"Protocol" : "HTTP"
},
{
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "443",
"Protocol" : "HTTPS",
"SSLCertificateId" : "arn:aws:iam::xxx"
}
],
"SecurityGroups" : [ "sg-a88444cc" ],
"Subnets" : [ "subnet-5ff05206", "subnet-b1109fc6", "subnet-948ce5f1" ]
}
}
如您所见,我的自动缩放组和负载均衡器的子网列表相同。显然我误解了它应该如何工作,但我无法解决。
尝试为自动缩放组指定 AvailabilityZones
属性。默认情况下它使用所有区域,因此如果您的子网仅使用区域的子网,您将收到此错误消息。
(正如评论中指出的那样,"AvailabilityZones" : { "Fn::GetAZs" : "" }
应该可以解决问题。)
我正在尝试创建一个 EC2 实例,它将使用自动缩放,附加到负载均衡器。
很遗憾,我遇到了错误
The availability zones of the specified subnets and the AutoScalingGroup do not match
但是,这是我当前的 Cloudformation 脚本:
"ApiAutoScaling" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"VPCZoneIdentifier" : [ "subnet-5ff05206", "subnet-b1109fc6", "subnet-948ce5f1" ],
"InstanceId" : {
"Ref" : "ApiEC2"
},
"MaxSize" : 3,
"MinSize" : 1,
"LoadBalancerNames" : [ "Api" ]
}
},
"ApiLoadBalancer" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"LoadBalancerName" : "Api",
"Listeners" : [
{
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "80",
"Protocol" : "HTTP"
},
{
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "443",
"Protocol" : "HTTPS",
"SSLCertificateId" : "arn:aws:iam::xxx"
}
],
"SecurityGroups" : [ "sg-a88444cc" ],
"Subnets" : [ "subnet-5ff05206", "subnet-b1109fc6", "subnet-948ce5f1" ]
}
}
如您所见,我的自动缩放组和负载均衡器的子网列表相同。显然我误解了它应该如何工作,但我无法解决。
尝试为自动缩放组指定 AvailabilityZones
属性。默认情况下它使用所有区域,因此如果您的子网仅使用区域的子网,您将收到此错误消息。
(正如评论中指出的那样,"AvailabilityZones" : { "Fn::GetAZs" : "" }
应该可以解决问题。)