title: How do I assign a created SecurityGroup to an ELB from CloudFormation?
body: <p>I've got a CloudFormation script that generates a SecurityGroup and an ELB; I'm trying to reference the SecurityGroup in the ELB creation; here's the resources bit:</p>
  
  <pre><code>    "ELBSecurityGroup" : {
          "Type" : "AWS::EC2::SecurityGroup",
          "Properties" : {
              "GroupDescription" : "Security group for the Arena dev stack",
              "SecurityGroupIngress" : [
                  {"IpProtocol" : "tcp", "FromPort" : 80, "ToPort" : 80, "CidrIp" : { "Ref" : "OfficeIp" }}
              ]
          }
      },
  
      "ProjectLoadBalancerTest" : {
          "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
          "Properties" : {
              "AvailabilityZones" : { "Fn::GetAZs" : "" },
              "Instances" : [  ],
              "Listeners" : [ {
                  "LoadBalancerPort" : "80",
                  "InstancePort" : "12345",
                  "Protocol" : "HTTP"
              } ],
              "HealthCheck" : {
                  "Target" : {
                      "Fn::Join" : [ "", [ "HTTP:", "12345", "/status.json" ] ]
                  },
                  "HealthyThreshold" : "2",
                  "UnhealthyThreshold" : "5",
                  "Interval" : "60",
                  "Timeout" : "30"
              },
              "SecurityGroups" : [
                  { "Ref" : "ELBSecurityGroup" }
              ]
          }
      }
  </code></pre>
  
  <p>Unfortunately, this fails with:</p>
  
  <pre><code>Invalid id: "sebelbtest2-ELBSecurityGroup-1F5Z5DIIVQKD1" (expecting "sg-...")
  </code></pre>
  
  <p>So how can I reference ELBSecurityGroup for use as a property in the ELB creation?</p>
  
  <p>Thanks!</p>