-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WAF policy resource, managed WAF rulesets data source, and waf_policy…
…_id in build settings
- Loading branch information
Showing
37 changed files
with
5,925 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/swagger_go.json | ||
/.env | ||
*.out | ||
/waf | ||
|
||
*.dll | ||
*.exe | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "netlify_managed_waf_rules Data Source - netlify" | ||
subcategory: "" | ||
description: |- | ||
Netlify managed WAF rule sets. This should be used when defining a WAF policy (netlify_waf_policy). | ||
--- | ||
|
||
# netlify_managed_waf_rules (Data Source) | ||
|
||
Netlify managed WAF rule sets. This should be used when defining a WAF policy (netlify_waf_policy). | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# Read-only definitions of all managed WAF rules available in Netlify. | ||
# The team ID is required to query the rules. | ||
data "netlify_managed_waf_rules" "example" { | ||
team_id = "6600abcdef1234567890abcd" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `team_id` (String) | ||
|
||
### Read-Only | ||
|
||
- `rule_sets` (Attributes Map) (see [below for nested schema](#nestedatt--rule_sets)) | ||
|
||
<a id="nestedatt--rule_sets"></a> | ||
### Nested Schema for `rule_sets` | ||
|
||
Read-Only: | ||
|
||
- `definition` (Attributes) (see [below for nested schema](#nestedatt--rule_sets--definition)) | ||
- `rules` (Attributes List) (see [below for nested schema](#nestedatt--rule_sets--rules)) | ||
|
||
<a id="nestedatt--rule_sets--definition"></a> | ||
### Nested Schema for `rule_sets.definition` | ||
|
||
Read-Only: | ||
|
||
- `id` (String) | ||
- `type` (String) | ||
- `version` (String) | ||
|
||
|
||
<a id="nestedatt--rule_sets--rules"></a> | ||
### Nested Schema for `rule_sets.rules` | ||
|
||
Read-Only: | ||
|
||
- `category` (String) | ||
- `description` (String) | ||
- `id` (String) | ||
- `phase` (String) | ||
- `severity` (String) notice, warning, error, critical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "netlify_waf_policy Resource - netlify" | ||
subcategory: "" | ||
description: |- | ||
Netlify Web Application Firewall (WAF) policy. Read more https://docs.netlify.com/security/secure-access-to-sites/web-application-firewall/ | ||
--- | ||
|
||
# netlify_waf_policy (Resource) | ||
|
||
Netlify Web Application Firewall (WAF) policy. [Read more](https://docs.netlify.com/security/secure-access-to-sites/web-application-firewall/) | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "netlify_waf_policy" "example" { | ||
team_id = data.netlify_team.team.id | ||
name = "Terraform Ruleset" | ||
description = "This is a test ruleset through Terraform" | ||
rule_sets = [ | ||
{ | ||
managed_id = "crs-basic", | ||
passive_mode = true, | ||
overall_threshold = 5, | ||
category_thresholds = { | ||
"fixation" = 8, | ||
}, | ||
rule_overrides = { | ||
"920100" = { | ||
action = "log_only" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
# To use this policy in a site, use the netlify_site_build_settings resource: | ||
resource "netlify_site_build_settings" "example" { | ||
# other attributes... | ||
waf_policy_id = netlify_waf_policy.example.id | ||
} | ||
# To dynamically define the rule overrides, you can query netlify_managed_waf_rules to get the rule IDs: | ||
data "netlify_managed_waf_rules" "example" { | ||
team_id = "6600abcdef1234567890abcd" | ||
} | ||
resource "netlify_waf_policy" "example" { | ||
team_id = "66ae34e11a567e9092e3850f" | ||
name = "Terraform Ruleset" | ||
description = "This is a test ruleset through Terraform" | ||
rule_sets = [ | ||
{ | ||
managed_id = "crs-basic", | ||
passive_mode = true, | ||
overall_threshold = 5, | ||
rule_overrides = { | ||
for rule in data.netlify_managed_waf_rules.example.rule_sets["crs-basic"].rules : rule.id => { | ||
action = "log_only" | ||
} if rule.category == "rce" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `description` (String) | ||
- `name` (String) | ||
- `rule_sets` (Attributes List) (see [below for nested schema](#nestedatt--rule_sets)) | ||
- `team_id` (String) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `last_updated` (String) | ||
|
||
<a id="nestedatt--rule_sets"></a> | ||
### Nested Schema for `rule_sets` | ||
|
||
Required: | ||
|
||
- `managed_id` (String) The managed ID of the rule set. Currently, only crs-basic is supported. | ||
- `overall_threshold` (Number) Recommended default value is 5 | ||
- `passive_mode` (Boolean) | ||
|
||
Optional: | ||
|
||
- `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 | ||
- `excluded_patterns` (List of String) | ||
- `rule_overrides` (Attributes Map) (see [below for nested schema](#nestedatt--rule_sets--rule_overrides)) | ||
|
||
<a id="nestedatt--rule_sets--rule_overrides"></a> | ||
### Nested Schema for `rule_sets.rule_overrides` | ||
|
||
Required: | ||
|
||
- `action` (String) log_only or none | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Import a WAF policy by its team ID and the policy ID | ||
terraform import netlify_log_drain.http 6600abcdef1234567890abcd:6600abcdef1234567890abcd | ||
``` |
5 changes: 5 additions & 0 deletions
5
examples/data-sources/netlify_managed_waf_rules/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Read-only definitions of all managed WAF rules available in Netlify. | ||
# The team ID is required to query the rules. | ||
data "netlify_managed_waf_rules" "example" { | ||
team_id = "6600abcdef1234567890abcd" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Import a WAF policy by its team ID and the policy ID | ||
terraform import netlify_log_drain.http 6600abcdef1234567890abcd:6600abcdef1234567890abcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
resource "netlify_waf_policy" "example" { | ||
team_id = data.netlify_team.team.id | ||
name = "Terraform Ruleset" | ||
description = "This is a test ruleset through Terraform" | ||
rule_sets = [ | ||
{ | ||
managed_id = "crs-basic", | ||
passive_mode = true, | ||
overall_threshold = 5, | ||
category_thresholds = { | ||
"fixation" = 8, | ||
}, | ||
rule_overrides = { | ||
"920100" = { | ||
action = "log_only" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
||
# To use this policy in a site, use the netlify_site_build_settings resource: | ||
|
||
resource "netlify_site_build_settings" "example" { | ||
# other attributes... | ||
waf_policy_id = netlify_waf_policy.example.id | ||
} | ||
|
||
# To dynamically define the rule overrides, you can query netlify_managed_waf_rules to get the rule IDs: | ||
|
||
data "netlify_managed_waf_rules" "example" { | ||
team_id = "6600abcdef1234567890abcd" | ||
} | ||
|
||
resource "netlify_waf_policy" "example" { | ||
team_id = "66ae34e11a567e9092e3850f" | ||
name = "Terraform Ruleset" | ||
description = "This is a test ruleset through Terraform" | ||
rule_sets = [ | ||
{ | ||
managed_id = "crs-basic", | ||
passive_mode = true, | ||
overall_threshold = 5, | ||
rule_overrides = { | ||
for rule in data.netlify_managed_waf_rules.example.rule_sets["crs-basic"].rules : rule.id => { | ||
action = "log_only" | ||
} if rule.category == "rce" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.