-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Conversation
Ref: hashicorp#2291 Even though hashicorp#9710 fixed one case of the problem, there is another case which is harder to reproduce. When a network acl has ingress and egress with same rule number, which is valid per aws doc, if one of them missing (maybe manually deleted), then terraform plan will stop working. The main problem is there is a change in aws api and the egress filter is not supported anymore. Current doc: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNetworkAcls.html 2017 doc: https://web.archive.org/web/20171216154650/http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNetworkAcls.html Noted `entry.egress` is gone. So the query return the nacl with same number rule but not which correct type. Which make this for loop https://github.com/terraform-providers/terraform-provider-aws/blob/5348ed3f1c47900f18c7f457a920de5f33cf7142/aws/resource_aws_network_acl_rule.go#L298 couldn't find the correct rule and fall down to the wrong return https://github.com/terraform-providers/terraform-provider-aws/blob/5348ed3f1c47900f18c7f457a920de5f33cf7142/aws/resource_aws_network_acl_rule.go#L304 The fix simple `return nil, nil` so the rule will be deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix, @voanhduy1512 🚀
Output from acceptance testing:
--- PASS: TestAccAWSNetworkAclRule_missingParam (10.12s)
--- PASS: TestAccAWSNetworkAclRule_disappears_NetworkAcl (15.26s)
--- PASS: TestAccAWSNetworkAclRule_ipv6ICMP (16.77s)
--- PASS: TestAccAWSNetworkAclRule_ipv6 (18.20s)
--- PASS: TestAccAWSNetworkAclRule_disappears (18.34s)
--- PASS: TestAccAWSNetworkAclRule_ingressEgressSameNumberDisappears (19.04s)
--- PASS: TestAccAWSNetworkAclRule_basic (23.17s)
--- PASS: TestAccAWSNetworkAclRule_tcpProtocol (25.58s)
--- PASS: TestAccAWSNetworkAclRule_allProtocol (26.55s)
--- PASS: TestAccAWSNetworkAclRule_ipv6VpcAssignGeneratedIpv6CidrBlockUpdate (29.09s)
This has been released in version 2.48.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Ref: #2291
Even though
#9710
fixed one case of the problem, there is another case which is harder to
reproduce.
When a network acl has ingress and egress with same rule number, which
is valid per aws doc, if one of them missing (maybe manually deleted),
then terraform plan will stop working.
The main problem is there is a change in aws api and the egress filter
is not supported anymore.
Current doc: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNetworkAcls.html
2017 doc: https://web.archive.org/web/20171216154650/http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNetworkAcls.html
Noted
entry.egress
is gone. So the query return the nacl with samenumber rule but not which correct type. Which make this for loop
https://github.com/terraform-providers/terraform-provider-aws/blob/5348ed3f1c47900f18c7f457a920de5f33cf7142/aws/resource_aws_network_acl_rule.go#L298
couldn't find the correct rule and fall down to the wrong return https://github.com/terraform-providers/terraform-provider-aws/blob/5348ed3f1c47900f18c7f457a920de5f33cf7142/aws/resource_aws_network_acl_rule.go#L304
The fix simple
return nil, nil
so the rule will be deletedCommunity Note
Relates OR Closes #0000
Release note for CHANGELOG:
Output from acceptance testing: