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

Add AWS WAFv2 labels on web requests #19486

Closed mcab closed 2 years ago

mcab commented 3 years ago

Community Note

Description

A label is metadata that a rule can add to matching web requests. Rules can also match against labels when they inspect web requests. Labels allow a matching rule to communicate results to the rules that are evaluated later in the same web ACL.

(from [1])

This would allow for strings to be attached during requests matching certain rules. Additionally, this would allow for a LabelMatchStatement to be applied to rules (see [2]).

This allows for:

New or Affected Resource(s)

New:

Affected:

Potential Terraform Configuration

Labels when used in aws_wafv2_rule_group ```hcl # Assuming 111122223333 is the AWS account ID, mirroring [7]. resource "aws_wafv2_rule_group" "testRules" { [...] rule { name = "rule-1" statement { [...] } label { label_name = "testNS1:testNestedNS1:label1" # outputs awswaf:111122223333:rulegroup:testRules:testNS1:testNestedNS1:label1 label_name = "testNS1:label2" # outputs awswaf:111122223333:rulegroup:testRules:testNS1:label2 label_name = "label3" # outputs awswaf:111122223333:rulegroup:testRules:label3 } [...] } rule { name = "conditions-on-rule-1-A" action { count {} } statement { label_match_statement { scope = "LABEL" key = "label3" } } [...] } rule { name = "conditions-on-rule-1-B" action { block {} } statement { label_match_statement { scope = "NAMESPACE" key = "awswaf:111122223333:rulegroup:testRules:testNS1" } } [...] } [...] } ```
Labels when used in aws_wafv2_web_acl ```hcl # Assuming 111122223333 is the AWS account ID, mirroring [7]. resource "aws_wafv2_web_acl" "testAppWebACLA" { name = "testAppA" [...] default_action { allow {} } rule { name = "rule-2" [...] action { count {} } statement { [...] } label { label_name = "testNS2:testNestedNS2:label4" # outputs awswaf:111122223333:webacl:testApp:testNS2:testNestedNS2:label4 label_name = "testNS2:label5" # outputs awswaf:111122223333:webacl:testApp:testNS2:label5 label_name = "label6" # outputs awswaf:111122223333:webacl:testApp:label6 } [...] } rule { name = "conditions-on-rule-2-A" [...] action { count {} } statement { label_match_statement { scope = "LABEL" key = "label6" } } [...] } rule { name = "conditions-on-rule-2-B" [...] action { count {} } statement { label_match_statement { scope = "NAMESPACE" key = "awswaf:111122223333:webacl:testApp:testNS2" } } [...] } [...] } ```

References

andyalm commented 3 years ago

I have started work on this here

bushong1 commented 3 years ago

Any word on this? Feels stalled despite a complete PR...

hatched-DavidMichon commented 3 years ago

Any progress on this? Waiting eagerly on this new statement support

hhamalai commented 3 years ago

Without this feature merged, we are required to run non-terraform tooling to setup these labels in order to filter log events from WAF request logs. Crucial feature when you're not willing to log everything, but only the traffic matching to your WAF rules.

vat-gatepost-BARQUE commented 3 years ago

Any updates on this?

breathingdust commented 2 years ago

Hi all πŸ‘‹ Just letting you know that this is issue is featured on this quarters roadmap. If a PR exists to close the issue a maintainer will review and either make changes directly, or work with the original author to get the contribution merged. If you have written a PR to resolve the issue please ensure the "Allow edits from maintainers" box is checked. Thanks for your patience and we are looking forward to getting this merged soon!

github-actions[bot] commented 2 years ago

This functionality has been released in v3.67.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. Thank you!

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.