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_security_group_rule: Support all non-zero from_port and to_port configurations with protocol ALL/-1 #6423

Merged
merged 1 commit into from
Nov 12, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Nov 10, 2018

Reference: #6407 (comment)

This completely suppresses from_port and to_port differences when protocol is ALL or -1. The API ignores them in this scenario, so previously it was possible to specify whatever non-zero values you wished (-1 for both, 0 and 65535, etc), but previously the logic was also not showing a difference.

Previously:

--- FAIL: TestAccAWSSecurityGroupRule_Description_AllPorts_NonZeroPorts (16.96s)
    testing.go:538: Step 0 error: After applying this step and refreshing, the plan was not empty:

        DIFF:

        DESTROY/CREATE: aws_security_group_rule.test
          cidr_blocks.#:            "1" => "1"
          cidr_blocks.0:            "0.0.0.0/0" => "0.0.0.0/0"
          description:              "description1" => "description1"
          from_port:                "0" => "-1" (forces new resource)
          protocol:                 "-1" => "-1"
          security_group_id:        "sg-04722579708a472f8" => "sg-04722579708a472f8"
          self:                     "false" => "false"
          source_security_group_id: "" => "<computed>"
          to_port:                  "0" => "-1" (forces new resource)
          type:                     "ingress" => "ingress"

Output from acceptance testing:

--- PASS: TestAccAWSSecurityGroupRule_ExpectInvalidTypeError (1.70s)
--- PASS: TestAccAWSSecurityGroupRule_ExpectInvalidCIDR (1.84s)
--- PASS: TestAccAWSSecurityGroupRule_MultiIngress (23.08s)
--- PASS: TestAccAWSSecurityGroupRule_EgressDescription (23.84s)
--- PASS: TestAccAWSSecurityGroupRule_Issue5310 (24.41s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_Classic (24.04s)
--- PASS: TestAccAWSSecurityGroupRule_MultipleRuleSearching_AllProtocolCrash (25.85s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_VPC (27.91s)
--- PASS: TestAccAWSSecurityGroupRule_IngressDescription (28.45s)
--- PASS: TestAccAWSSecurityGroupRule_Description_AllPorts_NonZeroPorts (30.69s)
--- PASS: TestAccAWSSecurityGroupRule_Egress (36.77s)
--- PASS: TestAccAWSSecurityGroupRule_IngressDescription_updates (37.11s)
--- PASS: TestAccAWSSecurityGroupRule_SelfSource (42.98s)
--- PASS: TestAccAWSSecurityGroupRule_EgressDescription_updates (43.95s)
--- PASS: TestAccAWSSecurityGroupRule_SelfReference (44.43s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_Ipv6 (45.83s)
--- PASS: TestAccAWSSecurityGroupRule_PartialMatching_Source (50.10s)
--- PASS: TestAccAWSSecurityGroupRule_PartialMatching_basic (51.93s)
--- PASS: TestAccAWSSecurityGroupRule_Description_AllPorts (52.00s)
--- PASS: TestAccAWSSecurityGroupRule_PrefixListEgress (57.10s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_Protocol (37.05s)
--- PASS: TestAccAWSSecurityGroupRule_MultiDescription (89.38s)
--- PASS: TestAccAWSSecurityGroupRule_Race (275.19s)

…d `to_port` configurations with `protocol` ALL/-1

This completely suppresses `from_port` and `to_port` differences when `protocol` is `ALL` or `-1`. The API ignores them in this scenario, so previously it was possible to specify whatever non-zero values you wished (-1 for both, 0 and 65535, etc), but previously the logic was not showing the difference.

Previously:

```
--- FAIL: TestAccAWSSecurityGroupRule_Description_AllPorts_NonZeroPorts (16.96s)
    testing.go:538: Step 0 error: After applying this step and refreshing, the plan was not empty:

        DIFF:

        DESTROY/CREATE: aws_security_group_rule.test
          cidr_blocks.#:            "1" => "1"
          cidr_blocks.0:            "0.0.0.0/0" => "0.0.0.0/0"
          description:              "description1" => "description1"
          from_port:                "0" => "-1" (forces new resource)
          protocol:                 "-1" => "-1"
          security_group_id:        "sg-04722579708a472f8" => "sg-04722579708a472f8"
          self:                     "false" => "false"
          source_security_group_id: "" => "<computed>"
          to_port:                  "0" => "-1" (forces new resource)
          type:                     "ingress" => "ingress"
```

Output from acceptance testing:

```
--- PASS: TestAccAWSSecurityGroupRule_ExpectInvalidTypeError (1.70s)
--- PASS: TestAccAWSSecurityGroupRule_ExpectInvalidCIDR (1.84s)
--- PASS: TestAccAWSSecurityGroupRule_MultiIngress (23.08s)
--- PASS: TestAccAWSSecurityGroupRule_EgressDescription (23.84s)
--- PASS: TestAccAWSSecurityGroupRule_Issue5310 (24.41s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_Classic (24.04s)
--- PASS: TestAccAWSSecurityGroupRule_MultipleRuleSearching_AllProtocolCrash (25.85s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_VPC (27.91s)
--- PASS: TestAccAWSSecurityGroupRule_IngressDescription (28.45s)
--- PASS: TestAccAWSSecurityGroupRule_Description_AllPorts_NonZeroPorts (30.69s)
--- PASS: TestAccAWSSecurityGroupRule_Egress (36.77s)
--- PASS: TestAccAWSSecurityGroupRule_IngressDescription_updates (37.11s)
--- PASS: TestAccAWSSecurityGroupRule_SelfSource (42.98s)
--- PASS: TestAccAWSSecurityGroupRule_EgressDescription_updates (43.95s)
--- PASS: TestAccAWSSecurityGroupRule_SelfReference (44.43s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_Ipv6 (45.83s)
--- PASS: TestAccAWSSecurityGroupRule_PartialMatching_Source (50.10s)
--- PASS: TestAccAWSSecurityGroupRule_PartialMatching_basic (51.93s)
--- PASS: TestAccAWSSecurityGroupRule_Description_AllPorts (52.00s)
--- PASS: TestAccAWSSecurityGroupRule_PrefixListEgress (57.10s)
--- PASS: TestAccAWSSecurityGroupRule_Ingress_Protocol (37.05s)
--- PASS: TestAccAWSSecurityGroupRule_MultiDescription (89.38s)
--- PASS: TestAccAWSSecurityGroupRule_Race (275.19s)
```
@bflad bflad added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service. labels Nov 10, 2018
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Nov 10, 2018
@@ -1922,7 +1921,7 @@ resource "aws_security_group_rule" "test" {
`, rName, description)
}

func testAccAWSSecurityGroupRuleConfigDescriptionAllPortsToPort65535(rName, description string) string {
func testAccAWSSecurityGroupRuleConfigDescriptionAllPortsNonZeroPorts(rName, description string) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-zero for both from_port and to_port also covers the previous scenario, which is why this was updated.

@bflad bflad requested a review from a team November 12, 2018 13:52
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bflad bflad added this to the v1.44.0 milestone Nov 12, 2018
@bflad bflad merged commit 561ed3e into master Nov 12, 2018
@bflad bflad deleted the b-aws_security_group_rule-diffsuppressfunc branch November 12, 2018 14:34
bflad added a commit that referenced this pull request Nov 12, 2018
@analytically
Copy link

Fixed my issue, nice one!

@bflad
Copy link
Contributor Author

bflad commented Nov 15, 2018

This has been released in version 1.44.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 2, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants