Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_network_acl_rule: Fix provider error when missing rule #11544

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aws/resource_aws_network_acl_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ func findNetworkAclRule(d *schema.ResourceData, meta interface{}) (*ec2.NetworkA
return i, nil
}
}
return nil, nil
}
return nil, fmt.Errorf(
"Expected the Network ACL to have Entries, got: %#v",
Expand Down
58 changes: 58 additions & 0 deletions aws/resource_aws_network_acl_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ func TestAccAWSNetworkAclRule_disappears(t *testing.T) {
})
}

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

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

func TestAccAWSNetworkAclRule_disappears_NetworkAcl(t *testing.T) {
var networkAcl ec2.NetworkAcl
resourceName := "aws_network_acl.bar"
Expand Down Expand Up @@ -555,6 +575,44 @@ resource "aws_network_acl_rule" "baz" {
}
`

const testAccAWSNetworkAclRuleIngressEgressSameNumberMissing = `
resource "aws_vpc" "foo" {
cidr_block = "10.3.0.0/16"
tags = {
Name = "terraform-testacc-network-acl-rule-ingress-egress-same-number-missing"
}
}

resource "aws_network_acl" "bar" {
vpc_id = "${aws_vpc.foo.id}"
tags = {
Name = "tf-acc-acl-rule-basic"
}
}

resource "aws_network_acl_rule" "baz" {
network_acl_id = "${aws_network_acl.bar.id}"
rule_number = 100
egress = false
protocol = "tcp"
rule_action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 22
to_port = 22
}

resource "aws_network_acl_rule" "qux" {
network_acl_id = "${aws_network_acl.bar.id}"
rule_number = 100
egress = true
protocol = "tcp"
rule_action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 22
to_port = 22
}
`

func testAccAWSNetworkAclRuleConfigIpv6ICMP(rName string) string {
return fmt.Sprintf(`
resource "aws_vpc" "test" {
Expand Down