hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.84k stars 9.19k forks source link

aws_wafv2_web_acl AWSManagedRulesCommonRuleSet keeps on detecting changes after apply #22678

Closed xtiannano closed 2 years ago

xtiannano commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Terraform v0.13.7 tried it both on aws v3.58.0 and aws v3.73.0 but still issue persists.

Affected Resource(s)

Terraform Configuration Files

+ rule {
         + name     = "aws-managed-rules-common-rules"
         + priority = 1

          + override_action {
              + count {}
            }
          + statement {
              + managed_rule_group_statement {
                  + name        = "AWSManagedRulesCommonRuleSet"
                  + vendor_name = "AWS"

                  + excluded_rule {
                      + name = "CrossSiteScripting_BODY"
                    }
                  + excluded_rule {
                      + name = "CrossSiteScripting_COOKIE"
                    }
                  + excluded_rule {
                      + name = "CrossSiteScripting_QUERYARGUMENTS"
                    }
                  + excluded_rule {
                      + name = "CrossSiteScripting_URIPATH"
                    }
                  + excluded_rule {
                      + name = "EC2MetaDataSSRF_BODY"
                    }
                  + excluded_rule {
                      + name = "EC2MetaDataSSRF_COOKIE"
                    }
                  + excluded_rule {
                      + name = "EC2MetaDataSSRF_QUERYARGUMENTS"
                    }
                  + excluded_rule {
                      + name = "EC2MetaDataSSRF_URIPATH"
                    }
                  + excluded_rule {
                      + name = "GenericLFI_BODY"
                    }
                  + excluded_rule {
                      + name = "GenericLFI_QUERYARGUMENTS"
                    }
                  + excluded_rule {
                      + name = "GenericLFI_URIPATH"
                    }
                  + excluded_rule {
                      + name = "GenericRFI_BODY"
                    }
                  + excluded_rule {
                      + name = "GenericRFI_QUERYARGUMENTS"
                    }
                  + excluded_rule {
                      + name = "GenericRFI_URIPATH"
                    }
                  + excluded_rule {
                      + name = "GenericRFI_BODY"
                    }
                  + excluded_rule {
                      + name = "NoUserAgent_HEADER"
                    }
                  + excluded_rule {
                      + name = "RestrictedExtensions_QUERYARGUMENTS"
                    }
                  + excluded_rule {
                      + name = "RestrictedExtensions_URIPATH"
                    }
                  + excluded_rule {
                      + name = "SizeRestrictions_Cookie_HEADER"
                    }
                  + excluded_rule {
                      + name = "SizeRestrictions_QUERYSTRING"
                    }
                  + excluded_rule {
                      + name = "SizeRestrictions_URIPATH"
                    }
                  + excluded_rule {
                      + name = "UserAgent_BadBots_HEADER"
                    }
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "aws-managed-rules-common-rules"
              + sampled_requests_enabled   = true
            }
        }
      - rule {
          - name     = "aws-managed-rules-common-rules" -> null
          - priority = 1 -> null

          - override_action {
              - count {}
            }

          - statement {

              - managed_rule_group_statement {
                  - name        = "AWSManagedRulesCommonRuleSet" -> null
                  - vendor_name = "AWS" -> null

                  - excluded_rule {
                      - name = "CrossSiteScripting_BODY" -> null
                    }
                  - excluded_rule {
                      - name = "CrossSiteScripting_COOKIE" -> null
                    }
                  - excluded_rule {
                      - name = "CrossSiteScripting_QUERYARGUMENTS" -> null
                    }
                  - excluded_rule {
                      - name = "CrossSiteScripting_URIPATH" -> null
                    }
                  - excluded_rule {
                      - name = "EC2MetaDataSSRF_BODY" -> null
                    }
                  - excluded_rule {
                      - name = "EC2MetaDataSSRF_COOKIE" -> null
                    }
                  - excluded_rule {
                      - name = "EC2MetaDataSSRF_QUERYARGUMENTS" -> null
                    }
                  - excluded_rule {
                      - name = "EC2MetaDataSSRF_URIPATH" -> null
                    }
                  - excluded_rule {
                      - name = "GenericLFI_BODY" -> null
                    }
                  - excluded_rule {
                      - name = "GenericLFI_QUERYARGUMENTS" -> null
                    }
                  - excluded_rule {
                      - name = "GenericLFI_URIPATH" -> null
                    }
                  - excluded_rule {
                      - name = "GenericRFI_BODY" -> null
                    }
                  - excluded_rule {
                      - name = "GenericRFI_QUERYARGUMENTS" -> null
                    }
                  - excluded_rule {
                      - name = "GenericRFI_URIPATH" -> null
                    }
                  - excluded_rule {
                      - name = "NoUserAgent_HEADER" -> null
                    }
                  - excluded_rule {
                      - name = "RestrictedExtensions_QUERYARGUMENTS" -> null
                    }
                  - excluded_rule {
                      - name = "RestrictedExtensions_URIPATH" -> null
                    }
                  - excluded_rule {
                      - name = "SizeRestrictions_Cookie_HEADER" -> null
                    }
                  - excluded_rule {
                      - name = "SizeRestrictions_QUERYSTRING" -> null
                    }
                  - excluded_rule {
                      - name = "SizeRestrictions_URIPATH" -> null
                    }
                  - excluded_rule {
                      - name = "UserAgent_BadBots_HEADER" -> null
                    }
                }
            }

          - visibility_config {
              - cloudwatch_metrics_enabled = true -> null
              - metric_name                = "aws-managed-rules-common-rules" -> null
              - sampled_requests_enabled   = true -> null
            }
        }

Expected Behavior

After applying it initially, a plan shouldn't be provided

Actual Behavior

After applying, a plan is provided to destroy and create the same rules again

Steps to Reproduce

  1. Create a resource aws_wafv2_web_acl , and define a rule to use a managed_rule_group_statement : AWSManagedRulesCommonRuleSet
  2. Create another resource, aws_wafv2_web_acl_association, referencing an existing AWS ALB to associate,
  3. Run terraform apply
justinretzolk commented 2 years ago

Hey @xtiannano 👋 Thank you for taking the time to raise this. So that we have all of the information we need in order to look into this, can you update the issue description to include the Terraform configuration itself (in addition to the diff that you already included -- thanks for that!) so that we can see how you're defining the resource(s)?

xtiannano commented 2 years ago

@justinretzolk thanks for taking the initiative to start triaging this and after careful checking on the rules, it was just due to a duplicate rule below that was causing the diff on the plan and after removing the duplicate, It doesn't detect anymore changes. Apologies for raising this and I shall go ahead and close this issue `- excluded_rule {

github-actions[bot] commented 2 years ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.