File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,8 +63,18 @@ these rules are spaced out to allow for custom rules to be inserted between.
6363| [ AWSManagedRulesAmazonIpReputationList] [ rules-ip-rep ] | 200 | Protects against IP addresses with a poor reputation. |
6464| [ AWSManagedRulesCommonRuleSet] [ rules-common ] | 300 | Protects against common threats. |
6565| [ AWSManagedRulesKnownBadInputsRuleSet] [ rules-inputs ] | 400 | Protects against known bad inputs. |
66+ | [ AWSManagedRulesBotControlRuleSet] [ rules-bot-control ] | 450 | (Optional, off by default) Protects against bots. |
6667| [ AWSManagedRulesSQLiRuleSet] [ rules-sqli ] | 500 | Protects against SQL injection attacks. |
6768
69+ The bot control rule set can be enabled as follows, at either TARGETED or COMMON inspection level:
70+
71+ ``` hcl
72+ bot_control = {
73+ enable = true
74+ inspection_level = "TARGETED"
75+ }
76+ ```
77+
6878## SSL Certificates
6979
7080By default, this module will use [ AWS Certificate Manager] [ acm ] (ACM) to manage
@@ -428,6 +438,7 @@ will be allowed through.
428438[ rules-common ] : https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-crs
429439[ rules-inputs ] : https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-known-bad-inputs
430440[ rules-ip-rep ] : https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-ip-rep.html#aws-managed-rule-groups-ip-rep-amazon
441+ [ rules-bot-control ] : https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-bot-control.html
431442[ rules-sqli ] : https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-use-case.html#aws-managed-rule-groups-use-case-sql-db
432443[ upload_paths ] : #upload_paths
433444[ wafv2_ip_set ] : https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/wafv2_ip_set
Original file line number Diff line number Diff line change @@ -86,6 +86,20 @@ variable "origin_domain" {
8686 default = null
8787}
8888
89+ variable "bot_control" {
90+ type = object ({
91+ enable = optional (bool , false )
92+ inspection_level = optional (string , " COMMON" )
93+ })
94+ description = " Bot Control managed rule group configuration."
95+ default = {}
96+
97+ validation {
98+ condition = contains ([" COMMON" , " TARGETED" ], var. bot_control . inspection_level )
99+ error_message = " inspection_level must be either \" COMMON\" or \" TARGETED\" ."
100+ }
101+ }
102+
89103variable "passive" {
90104 type = bool
91105 description = <<- EOT
Original file line number Diff line number Diff line change @@ -267,6 +267,46 @@ resource "aws_wafv2_web_acl" "waf" {
267267 }
268268 }
269269
270+ dynamic "rule" {
271+ for_each = var. bot_control . enable ? [true ] : []
272+
273+ content {
274+ name = " AWS-AWSManagedRulesBotControlRuleSet"
275+ priority = 450
276+
277+ override_action {
278+ dynamic "none" {
279+ for_each = var. passive ? [] : [true ]
280+ content {}
281+ }
282+
283+ dynamic "count" {
284+ for_each = var. passive ? [true ] : []
285+ content {}
286+ }
287+ }
288+
289+ statement {
290+ managed_rule_group_statement {
291+ name = " AWSManagedRulesBotControlRuleSet"
292+ vendor_name = " AWS"
293+
294+ managed_rule_group_configs {
295+ aws_managed_rules_bot_control_rule_set {
296+ inspection_level = var. bot_control . inspection_level
297+ }
298+ }
299+ }
300+ }
301+
302+ visibility_config {
303+ cloudwatch_metrics_enabled = true
304+ metric_name = " ${ local . prefix } -waf-bot-control"
305+ sampled_requests_enabled = true
306+ }
307+ }
308+ }
309+
270310 rule {
271311 name = " AWS-AWSManagedRulesSQLiRuleSet"
272312 priority = 500
You can’t perform that action at this time.
0 commit comments