Search code examples
aws-cloudformationaws-security-group

AWS CloudFormation template: Is it possible to add many CidrIp as a list?


I want to create the inbound rules of a security group in a CloudFormation template. I want to open the 3306 port from many different IPs.

"SecurityGroupIngress": [{
  "IpProtocol": "tcp",
  "CidrIp": "0.0.0.0/0",
  "FromPort": "3306",
  "ToPort": "3306"
}]

I know that the documentation says String as the CidrIp type but would it be possible to do something like this ["100.10.77.66/32", "100.10.66.66/32" , "101.10.77.66/32"] in order to avoid writing the same block many times?


Solution

  • Afraid not, as the documentation states it only accepts String and not List therefore multiple blocks are required.

    Think of it the same way as ingress rules are created within the web console, one new rule for each CIDR.