trussworks / terraform-aws-wafv2

Creates a WAF using AWS WAFv2 and AWS Managed Rule Sets
https://registry.terraform.io/modules/trussworks/wafv2
Apache License 2.0
104 stars 58 forks source link

Only log BLOCK requests #122

Closed asininemonkey closed 3 months ago

asininemonkey commented 1 year ago

Is your feature request related to a problem? Please describe. Enabling logging logs all requests

Describe the solution you'd like Option to log only BLOCK requests

Describe alternatives you've considered No other option beyond declaring the entire WAF resource myself

Additional context N/A

rdadlani commented 1 year ago

You could declare your own aws_wafv2_web_acl_logging_configuration and set the logging filter, like so:

  logging_filter {
    default_behavior = "KEEP"

    filter {
      behavior = "DROP"

      condition {
        action_condition {
          action = "ALLOW"
        }
      }
      requirement = "MEETS_ALL"
    }
  }

This has been my workaround for a while now using this module

asininemonkey commented 1 year ago

While that is a brilliant solution, having just tried it myself I see that my resource gets reverted by the module's own aws_wafv2_web_acl_logging_configuration.main[0] resource. Running apply numerous times just results in a ping ping replacement of one resource over the other.

Being able to control the module's own logging filter still appears to be the best solution unless the ping pong issue I've just described can also be solved.

rdadlani commented 1 year ago

It's hard to say more without first seeing your plan. My best guess without looking is that you may need/want to do some terraform state maneuvering.