title: Attaching multiple target group to AutoscalingGroup
body: <p>I'm designing a infrastucture solution to balance traffic to 2 different webapps, hosted in the same instance by different paths and ports.</p>
  
  <p>Im trying to do a Cloudformation to create an ALB, 1 listener, 2 target groups pointing to the instance that Autoscaling Group create, and 2 different listener rules with both targetgroups.</p>
  
  <p>As i read in AWS documentation, i must define inside AutoSG properties, the target groups, but i'm having problems to define it.</p>
  
  <p>I'm not sure either, that im doing correcty.</p>
  
  <p>I'm getting error message using this code (I think that this is the wrong part, when i do the reference in the autoscaling group creation, to the target groups)</p>
  
  <pre><code>       "TargetGroupARNs": [
                      {
                          "Ref": "DefaultTG"
                      },
                      {
                          "Ref": "SecondTG"
                      }
          ],
  </code></pre>
  
  <p>Those Target groups are defined like that:</p>
  
  <pre><code> "DefaultTG" : {
            "Type" : "AWS::ElasticLoadBalancingV2::TargetGroup",
            "Properties" : {
            "HealthCheckIntervalSeconds": 30,
            "HealthCheckProtocol": "HTTPS",
            "HealthCheckPath": "/home",
            "HealthCheckTimeoutSeconds": 10,
            "HealthyThresholdCount": 4,
            "Matcher" : {
            "HttpCode" : "200"
            },
            "Name": "Default",
            "Port": 4443,
            "Protocol": "HTTPS",
            "UnhealthyThresholdCount": 3,
            "VpcId": {"Ref" : "VpcID"}
      },
  </code></pre>
  
  <p>The code of listener and one listener rule:</p>
  
  <pre><code>   "ALBListener": {
        "Type": "AWS::ElasticLoadBalancingV2::Listener",
        "Properties": {
          "DefaultActions": [{
          "Type": "redirect",
              "RedirectConfig" : {
              "TargetGroupArn": { "Ref": "DefaultTG" }
              }
          }],
          "LoadBalancerArn": { "Ref": "APIServerELB" },
          "Port": "443",
          "Protocol": "TCP"
         }
      },
      "DefListenerRule": {
        "Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
        "Properties": {
            "Actions": [
                      {
                       "Type": "forward",
                       "TargetGroupArn": {
                       "Ref": "DefaultTG"
                      }
              }
              ],
            "Conditions" : [
                  {
                    "Field" : "path-pattern",
                    "Values" : [ "/home" ]
                  }
                ],
                  "ListenerArn": {
                      "Ref": "ALBListener"
                  }
            }
      },
  </code></pre>
  
  <p>And the error is:</p>
  
  <pre><code>Template validation error: Invalid template resource property 'DefaultTG'
  </code></pre>
  
  <p>I expect that the Cloudformation create one ALB with listener and 2 listener rules using 2 target groups pointing to the instances created by Autoscaling group.</p>