I'd like to create a CloudFormation template that creates a security group resource that allows ingress from a variable list of other security groups. The template would take a parameter of type List<AWS::EC2::SecurityGroup::Id>
. I'll name this parameter SourceSecurityGroupIds
for this example. Then, it would create a security group resource using something like:
{
"LogServerSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "XYZ security group",
"VpcId": "vpc-abcxyz",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": 1234,
"ToPort": 1234,
"SourceSecurityGroupId": { "Ref": "SourceSecurityGroupIds" }
}
]
}
}
}
Of course, the SourceSecurityGroupId
property of SecurityGroupIngress
doesn't take a list. Is there a way to make this work?
Update - Feb 27, 2019
In retrospect, the correct way to do this is to create a LogSourceSecurityGroup
, and allow ingress only from that security group. Then, add that security group to any EC2 instance, etc that should be able to communicate with the log server.