Skip to content

Commit

Permalink
Guard WAF rule_exclusion read (#330)
Browse files Browse the repository at this point in the history
* Wrap WAF configuration rule_exclusion read in a GetOK guard.

* Add beta warning block to WAF rule_exclusion documentation.
  • Loading branch information
phamann authored Oct 15, 2020
1 parent f02af04 commit 8ecff04
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 8 additions & 2 deletions fastly/resource_fastly_service_waf_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,14 @@ func resourceServiceWAFConfigurationV1Read(d *schema.ResourceData, meta interfac
return err
}

if err := readWAFRuleExclusions(meta, d, latestVersion.Number); err != nil {
return err
// As the rule exclusion API is still behind a beta feature
// flag, ensure we only read if the Set is non-empty.
//
// TODO(phamann): Remove d.GetOk() guard once in limited availability.
if _, ok := d.GetOk("rule_exclusion"); ok {
if err := readWAFRuleExclusions(meta, d, latestVersion.Number); err != nil {
return err
}
}

return nil
Expand Down
7 changes: 4 additions & 3 deletions website/docs/r/service_waf_configuration.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ resource "fastly_service_waf_configuration" "waf" {

Usage with rule exclusions:

~> **Warning:** Rule exclusions are part of a **beta release**, which may be subject to breaking changes and improvements over time. For more information, see our [product and feature lifecycle](https://docs.fastly.com/products/fastly-product-lifecycle#beta) descriptions.

```hcl
resource "fastly_service_v1" "demo" {
name = "demofastly"
Expand Down Expand Up @@ -599,13 +601,12 @@ The `rule` block supports:

The `rule_exclusion` block supports:

~> **Warning:** Rule exclusions are part of a **beta release**, which may be subject to breaking changes and improvements over time. For more information, see our [product and feature lifecycle](https://docs.fastly.com/products/fastly-product-lifecycle#beta) descriptions.

* `name` - (Required) The name of rule exclusion.
* `exclusion_type` - (Required) The type of rule exclusion. Values are `rule` to exclude the specified rule(s), or `waf` to disable the Web Application Firewall.
* `condition` - (Required) A conditional expression in VCL used to determine if the condition is met.
* `modsec_rule_ids` - (Required) Set of modsecurity IDs to be excluded. No rules should be provided when `exclusion_type` is `waf`. The rules need to be configured on the Web Application Firewall to be excluded.

The `rule_exclusion` block exports:

* `number` - The numeric ID assigned to the WAF Rule Exclusion.

## Import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ resource "fastly_service_waf_configuration" "waf" {

Usage with rule exclusions:

~> **Warning:** Rule exclusions are part of a **beta release**, which may be subject to breaking changes and improvements over time. For more information, see our [product and feature lifecycle](https://docs.fastly.com/products/fastly-product-lifecycle#beta) descriptions.

```hcl
resource "fastly_service_v1" "demo" {
name = "demofastly"
Expand Down Expand Up @@ -599,13 +601,12 @@ The `rule` block supports:

The `rule_exclusion` block supports:

~> **Warning:** Rule exclusions are part of a **beta release**, which may be subject to breaking changes and improvements over time. For more information, see our [product and feature lifecycle](https://docs.fastly.com/products/fastly-product-lifecycle#beta) descriptions.

* `name` - (Required) The name of rule exclusion.
* `exclusion_type` - (Required) The type of rule exclusion. Values are `rule` to exclude the specified rule(s), or `waf` to disable the Web Application Firewall.
* `condition` - (Required) A conditional expression in VCL used to determine if the condition is met.
* `modsec_rule_ids` - (Required) Set of modsecurity IDs to be excluded. No rules should be provided when `exclusion_type` is `waf`. The rules need to be configured on the Web Application Firewall to be excluded.

The `rule_exclusion` block exports:

* `number` - The numeric ID assigned to the WAF Rule Exclusion.

## Import
Expand Down

0 comments on commit 8ecff04

Please sign in to comment.