我正在尝试创建一个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" ]
}
}
如您所见,我的自动调节组和负载均衡器的子网列表相同。很明显,我误解了这应该如何运作,但我无法解决这个问题。
答案 0 :(得分:1)
尝试为自动缩放组指定AvailabilityZones
属性。默认是它使用所有这些,因此如果您的子网仅使用区域的子网,您将收到此错误消息。
(正如评论中所指出的那样,"AvailabilityZones" : { "Fn::GetAZs" : "" }
应该可以解决问题。)