|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "netlify_waf_policy Resource - netlify" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + Netlify Web Application Firewall (WAF) policy. Read more https://docs.netlify.com/security/secure-access-to-sites/web-application-firewall/ |
| 7 | +--- |
| 8 | + |
| 9 | +# netlify_waf_policy (Resource) |
| 10 | + |
| 11 | +Netlify Web Application Firewall (WAF) policy. [Read more](https://docs.netlify.com/security/secure-access-to-sites/web-application-firewall/) |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```terraform |
| 16 | +resource "netlify_waf_policy" "example" { |
| 17 | + team_id = data.netlify_team.team.id |
| 18 | + name = "Terraform Policy" |
| 19 | + description = "This is a test policy through Terraform" |
| 20 | + rule_sets = [ |
| 21 | + { |
| 22 | + managed_id = "crs-basic", |
| 23 | + passive_mode = true, |
| 24 | + overall_threshold = 5, |
| 25 | + category_thresholds = { |
| 26 | + "fixation" = 8, |
| 27 | + }, |
| 28 | + rule_overrides = { |
| 29 | + "920100" = { |
| 30 | + action = "log_only" |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + ] |
| 35 | +} |
| 36 | +
|
| 37 | +# To use this policy in a site, use the netlify_site_build_settings resource: |
| 38 | +
|
| 39 | +resource "netlify_site_build_settings" "example" { |
| 40 | + # other attributes... |
| 41 | + waf_policy_id = netlify_waf_policy.example.id |
| 42 | +} |
| 43 | +
|
| 44 | +# To dynamically define the rule overrides, you can query netlify_managed_waf_rules to get the rule IDs: |
| 45 | +
|
| 46 | +data "netlify_managed_waf_rules" "example" { |
| 47 | + team_id = "6600abcdef1234567890abcd" |
| 48 | +} |
| 49 | +
|
| 50 | +resource "netlify_waf_policy" "example" { |
| 51 | + team_id = "66ae34e11a567e9092e3850f" |
| 52 | + name = "Terraform Policy" |
| 53 | + description = "This is a test policy through Terraform" |
| 54 | + rule_sets = [ |
| 55 | + { |
| 56 | + managed_id = "crs-basic", |
| 57 | + passive_mode = true, |
| 58 | + overall_threshold = 5, |
| 59 | + rule_overrides = { |
| 60 | + for rule in data.netlify_managed_waf_rules.example.rule_sets["crs-basic"].rules : rule.id => { |
| 61 | + action = "log_only" |
| 62 | + } if rule.category == "rce" |
| 63 | + } |
| 64 | + } |
| 65 | + ] |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +<!-- schema generated by tfplugindocs --> |
| 70 | +## Schema |
| 71 | + |
| 72 | +### Required |
| 73 | + |
| 74 | +- `description` (String) |
| 75 | +- `name` (String) |
| 76 | +- `rule_sets` (Attributes List) (see [below for nested schema](#nestedatt--rule_sets)) |
| 77 | +- `team_id` (String) |
| 78 | + |
| 79 | +### Read-Only |
| 80 | + |
| 81 | +- `id` (String) The ID of this resource. |
| 82 | +- `last_updated` (String) |
| 83 | + |
| 84 | +<a id="nestedatt--rule_sets"></a> |
| 85 | +### Nested Schema for `rule_sets` |
| 86 | + |
| 87 | +Required: |
| 88 | + |
| 89 | +- `managed_id` (String) The managed ID of the rule set. Currently, only crs-basic is supported. |
| 90 | +- `overall_threshold` (Number) Recommended default value is 5 |
| 91 | +- `passive_mode` (Boolean) |
| 92 | + |
| 93 | +Optional: |
| 94 | + |
| 95 | +- `category_thresholds` (Map of Number) Thresholds for each category, e.g. fixation, injection-generic, injection-java, injection-php, lfi, protocol, rce, reputation-scanner, rfi, sqli, ssrf, xss |
| 96 | +- `excluded_patterns` (List of String) |
| 97 | +- `rule_overrides` (Attributes Map) (see [below for nested schema](#nestedatt--rule_sets--rule_overrides)) |
| 98 | + |
| 99 | +<a id="nestedatt--rule_sets--rule_overrides"></a> |
| 100 | +### Nested Schema for `rule_sets.rule_overrides` |
| 101 | + |
| 102 | +Required: |
| 103 | + |
| 104 | +- `action` (String) log_only or none |
| 105 | + |
| 106 | +## Import |
| 107 | + |
| 108 | +Import is supported using the following syntax: |
| 109 | + |
| 110 | +```shell |
| 111 | +# Import a WAF policy by its team ID and the policy ID |
| 112 | +terraform import netlify_waf_policy.main 6600abcdef1234567890abcd:6600abcdef1234567890abcd |
| 113 | +``` |
0 commit comments