title: AWS Autoscale Load Balancing with Cloudformation
body: <p>I'm trying to create an EC2 instance, that will use autoscaling, attached to a load balancer.</p>
  
  <p>Unfortunately, I'm getting the error</p>
  
  <pre><code>The availability zones of the specified subnets and the AutoScalingGroup do not match
  </code></pre>
  
  <p>However, this is my current Cloudformation script:</p>
  
  <pre class="lang-json prettyprint-override"><code>"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" ]
    }
  }
  </code></pre>
  
  <p>As you can see, my subnet list is the same for both my autoscaling group and my load balancer. Clearly I've misunderstood how this is supposed to work, but I can't work it out.</p>