Skip to content

Commit

Permalink
provider/aws: aws_network_acl_rule treat all and -1 for protocol the
Browse files Browse the repository at this point in the history
same

Fixes: #13012

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSNetworkAclRule_allProtocol'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/24 18:42:05 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSNetworkAclRule_allProtocol -timeout 120m
=== RUN   TestAccAWSNetworkAclRule_allProtocol
--- PASS: TestAccAWSNetworkAclRule_allProtocol (53.95s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	53.974s
```
  • Loading branch information
stack72 committed Mar 24, 2017
1 parent fc04f4b commit e076c58
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/providers/aws/resource_aws_network_acl_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func resourceAwsNetworkAclRule() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if old == "all" && new == "-1" {
return true
}
return false
},
},
"rule_action": {
Type: schema.TypeString,
Expand Down
37 changes: 37 additions & 0 deletions builtin/providers/aws/resource_aws_network_acl_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ func TestAccAWSNetworkAclRule_ipv6(t *testing.T) {
})
}

func TestAccAWSNetworkAclRule_allProtocol(t *testing.T) {
var networkAcl ec2.NetworkAcl

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSNetworkAclRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSNetworkAclRuleAllProtocolConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSNetworkAclRuleExists("aws_network_acl_rule.baz", &networkAcl),
),
ExpectNonEmptyPlan: false,
},
},
})
}

func TestResourceAWSNetworkAclRule_validateICMPArgumentValue(t *testing.T) {
type testCases struct {
Value string
Expand Down Expand Up @@ -250,6 +269,24 @@ resource "aws_network_acl_rule" "baz" {
to_port = 22
}
`
const testAccAWSNetworkAclRuleAllProtocolConfig = `
resource "aws_vpc" "foo" {
cidr_block = "10.3.0.0/16"
}
resource "aws_network_acl" "bar" {
vpc_id = "${aws_vpc.foo.id}"
}
resource "aws_network_acl_rule" "baz" {
network_acl_id = "${aws_network_acl.bar.id}"
rule_number = 150
egress = false
protocol = "-1"
rule_action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 22
to_port = 22
}
`

const testAccAWSNetworkAclRuleIpv6Config = `
resource "aws_vpc" "foo" {
Expand Down

0 comments on commit e076c58

Please sign in to comment.