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.82k stars 9.16k forks source link

Support record filtering for AWS WAF logging configuration #18665

Closed foxylion closed 3 years ago

foxylion commented 3 years ago

Community Note

Description

AWS WAF v2 supports to filter logs.

Log filtering – You can add filtering to specify which web requests are kept in the logs and which are dropped. You can filter on the rule action and on the web request labels that were applied during the request evaluation. For information about rule action settings, see AWS WAF rule action. For information about labels, see AWS WAF labels on web requests. see AWS docs

This allows reduction of logs that will be forwarded to Kinesis Firehose. Currently it is not possible to configure this behavior using Terraform.

New or Affected Resource(s)

Potential Terraform Configuration

The syntax is inspired by AWS API documentation for PutLoggingConfiguration.

resource "aws_wafv2_web_acl_logging_configuration" "example" {
  log_destination_configs = [aws_kinesis_firehose_delivery_stream.example.arn]
  resource_arn            = aws_wafv2_web_acl.example.arn
  filters {
    default_behavior = "DROP" # or "KEEP"
    filter {
      behavior = "KEEP" # or "DROP"
      requirement = "MEETS_ALL" # or "MEETS_ANY"
      conditions {
        action {
            action = "COUNT" # or "ALLOW" or "BLOCK"
        }
        label_name {
            label_name = "some-label-name"
        }
      }
    }
    filter {
      #...
    }
  }
}

References

ghost commented 3 years ago

This has been released in version 3.38.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!

foxylion commented 3 years ago

Awesome! Thank you @anGie44 for adding this functionality so quickly.

github-actions[bot] commented 3 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.