Skip to content

Commit 45da08c

Browse files
committed
Allow use of protocol numbers for ah and esp
1 parent 7b301d7 commit 45da08c

4 files changed

Lines changed: 66 additions & 6 deletions

File tree

builtin/providers/aws/network_acl_entry.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ func protocolIntegers() map[string]int {
8282
var protocolIntegers = make(map[string]int)
8383
protocolIntegers = map[string]int{
8484
// defined at https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
85-
"ah": 51,
86-
"esp": 50,
8785
"udp": 17,
8886
"tcp": 6,
8987
"icmp": 1,

builtin/providers/aws/resource_aws_security_group_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,48 @@ func TestAccAWSSecurityGroup_vpcNegOneIngress(t *testing.T) {
471471
},
472472
})
473473
}
474+
func TestAccAWSSecurityGroup_vpcProtoNumIngress(t *testing.T) {
475+
var group ec2.SecurityGroup
476+
477+
testCheck := func(*terraform.State) error {
478+
if *group.VpcId == "" {
479+
return fmt.Errorf("should have vpc ID")
480+
}
481+
482+
return nil
483+
}
484+
485+
resource.Test(t, resource.TestCase{
486+
PreCheck: func() { testAccPreCheck(t) },
487+
IDRefreshName: "aws_security_group.web",
488+
Providers: testAccProviders,
489+
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
490+
Steps: []resource.TestStep{
491+
resource.TestStep{
492+
Config: testAccAWSSecurityGroupConfigVpcProtoNumIngress,
493+
Check: resource.ComposeTestCheckFunc(
494+
testAccCheckAWSSecurityGroupExists("aws_security_group.web", &group),
495+
testAccCheckAWSSecurityGroupAttributesNegOneProtocol(&group),
496+
resource.TestCheckResourceAttr(
497+
"aws_security_group.web", "name", "terraform_acceptance_test_example"),
498+
resource.TestCheckResourceAttr(
499+
"aws_security_group.web", "description", "Used in the terraform acceptance tests"),
500+
resource.TestCheckResourceAttr(
501+
"aws_security_group.web", "ingress.956249133.protocol", "50"),
502+
resource.TestCheckResourceAttr(
503+
"aws_security_group.web", "ingress.956249133.from_port", "0"),
504+
resource.TestCheckResourceAttr(
505+
"aws_security_group.web", "ingress.956249133.to_port", "0"),
506+
resource.TestCheckResourceAttr(
507+
"aws_security_group.web", "ingress.956249133.cidr_blocks.#", "1"),
508+
resource.TestCheckResourceAttr(
509+
"aws_security_group.web", "ingress.956249133.cidr_blocks.0", "10.0.0.0/8"),
510+
testCheck,
511+
),
512+
},
513+
},
514+
})
515+
}
474516
func TestAccAWSSecurityGroup_MultiIngress(t *testing.T) {
475517
var group ec2.SecurityGroup
476518

@@ -1240,6 +1282,26 @@ resource "aws_security_group" "web" {
12401282
}
12411283
}
12421284
`
1285+
1286+
const testAccAWSSecurityGroupConfigVpcProtoNumIngress = `
1287+
resource "aws_vpc" "foo" {
1288+
cidr_block = "10.1.0.0/16"
1289+
}
1290+
1291+
resource "aws_security_group" "web" {
1292+
name = "terraform_acceptance_test_example"
1293+
description = "Used in the terraform acceptance tests"
1294+
vpc_id = "${aws_vpc.foo.id}"
1295+
1296+
ingress {
1297+
protocol = "50"
1298+
from_port = 0
1299+
to_port = 0
1300+
cidr_blocks = ["10.0.0.0/8"]
1301+
}
1302+
}
1303+
`
1304+
12431305
const testAccAWSSecurityGroupConfigMultiIngress = `
12441306
resource "aws_vpc" "foo" {
12451307
cidr_block = "10.1.0.0/16"

website/source/docs/providers/aws/r/security_group.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The `ingress` block supports:
8787
* `cidr_blocks` - (Optional) List of CIDR blocks.
8888
* `from_port` - (Required) The start port (or ICMP type number if protocol is "icmp")
8989
* `protocol` - (Required) The protocol. If you select a protocol of
90-
"-1", you must specify a "from_port" and "to_port" equal to 0.
90+
"-1", you must specify a "from_port" and "to_port" equal to 0. If not icmp, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)
9191
* `security_groups` - (Optional) List of security group Group Names if using
9292
EC2-Classic, or Group IDs if using a VPC.
9393
* `self` - (Optional) If true, the security group itself will be added as
@@ -100,7 +100,7 @@ The `egress` block supports:
100100
* `prefix_list_ids` - (Optional) List of prefix list IDs (for allowing access to VPC endpoints)
101101
* `from_port` - (Required) The start port (or ICMP type number if protocol is "icmp")
102102
* `protocol` - (Required) The protocol. If you select a protocol of
103-
"-1", you must specify a "from_port" and "to_port" equal to 0.
103+
"-1", you must specify a "from_port" and "to_port" equal to 0. If not icmp, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)
104104
* `security_groups` - (Optional) List of security group Group Names if using
105105
EC2-Classic, or Group IDs if using a VPC.
106106
* `self` - (Optional) If true, the security group itself will be added as
@@ -156,7 +156,7 @@ The following attributes are exported:
156156

157157
## Import
158158

159-
Security Groups can be imported using the `security group id`, e.g.
159+
Security Groups can be imported using the `security group id`, e.g.
160160

161161
```
162162
$ terraform import aws_security_group.elb_sg sg-903004f8

website/source/docs/providers/aws/r/security_group_rule.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ or `egress` (outbound).
4545
* `prefix_list_ids` - (Optional) List of prefix list IDs (for allowing access to VPC endpoints).
4646
Only valid with `egress`.
4747
* `from_port` - (Required) The start port (or ICMP type number if protocol is "icmp").
48-
* `protocol` - (Required) The protocol.
48+
* `protocol` - (Required) The protocol. If not icmp, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)
4949
* `security_group_id` - (Required) The security group to apply this rule to.
5050
* `source_security_group_id` - (Optional) The security group id to allow access to/from,
5151
depending on the `type`. Cannot be specified with `cidr_blocks`.

0 commit comments

Comments
 (0)