title: Allow every instance in the same Security Group to share any data between each other at Cloud Formation JSON?
body: <p>I'm building a Cloud Formation JSON to define EC2 Instances and Security Groups.</p>
  
  <p>I need to create a security Group that allows every instance that belongs in it to share any data between each other.</p>
  
  <p>My JSON was like that:</p>
  
  <pre><code>"InternalSecurityGroup" : {
    "Type" : "AWS::EC2::SecurityGroup",
    "Properties" : {
      "VpcId" : {"Ref" : "myVPC"},
      "GroupDescription" : "Allow the machines in this group to share all kinds of traffic between each other",
      "SecurityGroupIngress" : [
        {
          "IpProtocol" : "-1",
          "FromPort": "-1",
          "ToPort": "-1",
          "SourceSecurityGroupId" : { "Ref" : "InternalSecurityGroup" }
        }
      ],
      "SecurityGroupEgress" : [
        {
          "IpProtocol" : "-1",
          "FromPort": "-1",
          "ToPort": "-1",
          "DestinationSecurityGroupId" : { "Ref" : "InternalSecurityGroup" }
        }
      ]
  
    }
  },
  </code></pre>
  
  <p>But this shows me the following error:</p>
  
  <blockquote>
    <p>A client error (ValidationError) occurred when calling the CreateStack
    operation: Circular dependency between resources</p>
  </blockquote>
  
  <p>To fix it I changed my code to CidrIp instead of SourceSecurityGroupId, defining the subnet the instances are in.</p>
  
  <p>Is it possible to reference the same Security Group? What's the best (or correct) way to achieve what I want?</p>