---
layout: "fastly"
page_title: "Fastly: ngwaf_account_rule"
sidebar_current: "docs-fastly-resource-ngwaf-account-rule"
description: |-
  Provides a Fastly Next-Gen WAF Account Rule
---

# fastly_ngwaf_account_rule

Provides a Fastly Next-Gen WAF Account Rule.  
Account-level rules apply across one or more workspaces and are useful for defining shared or global WAF logic.

## Example Usage

Basic usage:

```terraform
resource "fastly_ngwaf_account_rule" "example" {
  applies_to       = ["*"]
  type             = "request"
  description      = "example"
  enabled          = true
  request_logging  = "sampled"
  group_operator   = "all"

  action {
    type = "block"
  }

  condition {
    field    = "ip"
    operator = "equals"
    value    = "1.2.3.4"
  }

  group_condition {
    group_operator = "all"

    condition {
      field    = "method"
      operator = "equals"
      value    = "POST"
    }
  }
}
```

## Import

Fastly Next-Gen WAF account rules can be imported using just the rule ID, e.g.:

```sh
$ terraform import fastly_ngwaf_account_rule.demo <ruleID>
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `action` (Block List, Min: 1) List of actions to perform when the rule matches. (see [below for nested schema](#nestedblock--action))
- `applies_to` (List of String) The list of workspace IDs this signal applies to, or the wildcard `*` if it applies to all workspaces.
- `description` (String) The description of the rule.
- `enabled` (Boolean) Whether the rule is currently enabled.
- `type` (String) The type of the rule. Accepted values are `request` and `signal`.

### Optional

- `condition` (Block List) Flat list of individual conditions. Each must include `field`, `operator`, and `value`. (see [below for nested schema](#nestedblock--condition))
- `group_condition` (Block List) List of grouped conditions with nested logic. Each group must define a `group_operator` and at least one condition or multival_condition. (see [below for nested schema](#nestedblock--group_condition))
- `group_operator` (String) Logical operator to apply to group conditions. Accepted values are `any` and `all`.
- `multival_condition` (Block List) List of multival conditions with nested logic. Each multival list must define a `field, operator, group_operator` and at least one condition. (see [below for nested schema](#nestedblock--multival_condition))
- `request_logging` (String) Logging behavior for matching requests. Accepted values are `sampled` and `none`.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--action"></a>
### Nested Schema for `action`

Required:

- `type` (String) The action type. One of: `add_signal`, `allow`, `block`, `browser_challenge`, `dynamic_challenge`, `exclude_signal`, `verify_token` or for rate limit rule valid values: `log_request`, `block_signal`, `browser_challenge`, `verify_token`

Optional:

- `signal` (String) Signal name to exclude (used when `type = exclude_signal`).


<a id="nestedblock--condition"></a>
### Nested Schema for `condition`

Required:

- `field` (String) Field to inspect (e.g., `ip`, `path`).
- `operator` (String) Operator to apply. One of: `equals`, `does_not_equal`, `contains`, `does_not_contain`, `like`, `not_like`, `in_list`, `not_in_list`, `matches`, `does_not_match`, `greater_equal`, `lesser_equal`.
- `value` (String) The value to test the field against.


<a id="nestedblock--group_condition"></a>
### Nested Schema for `group_condition`

Required:

- `group_operator` (String) Logical operator for the group. Accepted values are `any` and `all`.

Optional:

- `condition` (Block List) A list of nested conditions in this group. (see [below for nested schema](#nestedblock--group_condition--condition))
- `multival_condition` (Block List) List of nested multival conditions in this group. Each multival list must define a `field, operator, group_operator` and at least one condition. (see [below for nested schema](#nestedblock--group_condition--multival_condition))

<a id="nestedblock--group_condition--condition"></a>
### Nested Schema for `group_condition.condition`

Required:

- `field` (String) Field to inspect (e.g., `ip`, `path`).
- `operator` (String) Operator to apply. One of: `equals`, `does_not_equal`, `contains`, `does_not_contain`, `like`, `not_like`, `in_list`, `not_in_list`, `matches`, `does_not_match`, `greater_equal`, `lesser_equal`.
- `value` (String) The value to test the field against.


<a id="nestedblock--group_condition--multival_condition"></a>
### Nested Schema for `group_condition.multival_condition`

Required:

- `condition` (Block List, Min: 1) A list of nested conditions in this multival. (see [below for nested schema](#nestedblock--group_condition--multival_condition--condition))
- `field` (String) Enums for multival condition field. Accepted values are `post_parameter`, `query_parameter`, `request_cookie`, `request_header`, `response_header`, and `signal`.
- `group_operator` (String) Logical operator for the multival condition. Accepted values are `any` and `all`.
- `operator` (String) Indicates whether the supplied conditions will check for existence or non-existence of matching field values. Accepted values are `exists` and `does_not_exist`.

<a id="nestedblock--group_condition--multival_condition--condition"></a>
### Nested Schema for `group_condition.multival_condition.condition`

Required:

- `field` (String) Field to inspect (e.g., `name`, `value`, `signal_id`).
- `operator` (String) Operator to apply (e.g., `equals`, `contains`).
- `value` (String) The value to test the field against.




<a id="nestedblock--multival_condition"></a>
### Nested Schema for `multival_condition`

Required:

- `condition` (Block List, Min: 1) A list of nested conditions in this list. (see [below for nested schema](#nestedblock--multival_condition--condition))
- `field` (String) Enums for multival condition field.. Accepted values are `post_parameter`, `query_parameter`, `request_cookie`, `request_header`, `response_header`, and `signal`.
- `group_operator` (String) Logical operator for the group. Accepted values are `any` and `all`.
- `operator` (String) Indicates whether the supplied conditions will check for existence or non-existence of matching field values. Accepted values are `exists` and `does_not_exist`.

<a id="nestedblock--multival_condition--condition"></a>
### Nested Schema for `multival_condition.condition`

Required:

- `field` (String) Field to inspect (e.g., `name`, `value`, `signal_id`).
- `operator` (String) Operator to apply. One of: `equals`, `does_not_equal`, `contains`, `does_not_contain`, `like`, `not_like`, `in_list`, `not_in_list`, `matches`, `does_not_match`, `greater_equal`, `lesser_equal`.
- `value` (String) The value to test the field against.
