24

I have my CloudFormation script like this now:

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

and it looks like this, which is fine:

enter image description here

But I am wondering how to I update the template to get this:

enter image description here

Notice the Ports say All. I also wonder if they are different?

helloV
  • 42,534
  • 4
  • 100
  • 125
Steven Yong
  • 3,775
  • 5
  • 25
  • 47

3 Answers3

17

The original solution I posted (and accepted by the original poster) stopped working as AWS no longer supports it. To avoid the barrage of downvotes, I deleted the answer. The alternatives are:

  • Specify the ports 0 and 65535

or

Open all ports for all protocols not just TCP (as suggested by thewire247 below)

"SecurityGroupIngress" : [{
  "IpProtocol" : "-1",
  "CidrIp" : "0.0.0.0/0"
}]
helloV
  • 42,534
  • 4
  • 100
  • 125
  • 23
    Unfortunately, this seems not to work (at least not anymore). I tried this and got `TCP/UDP (from) port (-1) out of range`. I had to specify `0` and `65535` explicitly :( – geerlingguy Aug 02 '17 at 16:46
12

If you are looking to allow all protocols and all ports, then you can do the following

{
  "IpProtocol" : "-1"
  "CidrIp" : "0.0.0.0/0"
}
thewire247
  • 695
  • 1
  • 6
  • 22
3

FromPort
Start of port range for the TCP and UDP protocols, or an ICMP type number. If you specify icmp for the IpProtocol property, you can specify -1 as a wildcard (i.e., any ICMP type number).

ToPort
End of port range for the TCP and UDP protocols, or an ICMP code. If you specify icmp for the IpProtocol property, you can specify -1 as a wildcard (i.e., any ICMP code).

ex.
{ "IpProtocol" : "icmp", "FromPort" : "8", "ToPort" : "-1", "CidrIp" : "10.0.0.0/24" }

ref:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-ingress.html

Thomas Fritsch
  • 7,861
  • 33
  • 31
  • 41