{
    "AWSTemplateFormatVersion" : "2010-09-09",

    "Description" : "AWS CloudFormation Sample Template Mutually_Referencing_EC2_Security_Groups: Sample template showing how to create 2 EC2 security groups that mutually reference each other",

    "Resources" : {
        "SGroup1" : {
            "Type" : "AWS::EC2::SecurityGroup",
            "Properties" : {
                "GroupDescription" : "EC2 Instance access"
            }
        },
        "SGroup2" : {
            "Type" : "AWS::EC2::SecurityGroup",
            "Properties" : {
                "GroupDescription" : "EC2 Instance access"
            }
        },
        "SGroup1Ingress" : {
            "Type" : "AWS::EC2::SecurityGroupIngress",
            "Properties" : {
                "GroupName" : { "Ref" : "SGroup1" },
                "IpProtocol" : "tcp",
                "ToPort" : "80",
                "FromPort" : "80",
                "SourceSecurityGroupName" : { "Ref" : "SGroup2" }
            }
        },
        "SGroup2Ingress" : {
            "Type" : "AWS::EC2::SecurityGroupIngress",
            "Properties" : {
                "GroupName" : { "Ref" : "SGroup2" },
                "IpProtocol" : "tcp",
                "ToPort" : "80",
                "FromPort" : "80",
                "SourceSecurityGroupName" : { "Ref" : "SGroup1" }
            }
        }
    }
}
