|
| 1 | +--- |
| 2 | +layout: "wallarm" |
| 3 | +page_title: "Wallarm: wallarm_rule_api_abuse_mode" |
| 4 | +subcategory: "Rules" |
| 5 | +description: |- |
| 6 | + Enables or disables API Abuse Prevention for requests matching an action scope. |
| 7 | +--- |
| 8 | + |
| 9 | +# wallarm_rule_api_abuse_mode |
| 10 | + |
| 11 | +Provides the resource to toggle [API Abuse Prevention][1] for traffic matching a given action scope. Typical use: allowlist trusted crawlers (Pinterest, Google, monitoring agents) by applying `mode = "disabled"` to requests that carry their signature (User-Agent, path, method, etc.). |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```hcl |
| 16 | +# Disable API Abuse Prevention for legitimate Pinterest crawler traffic. |
| 17 | +
|
| 18 | +resource "wallarm_rule_api_abuse_mode" "pinterest" { |
| 19 | + mode = "disabled" |
| 20 | + title = "Allow Pinterest" |
| 21 | + comment = "Allow Pinterest through API Abuse Prevention" |
| 22 | +
|
| 23 | + action { |
| 24 | + type = "regex" |
| 25 | + value = ".*(Pinterest|Pinterestbot)/(0.2|1.0);?\\s[(]?[+]https?://www[.]pinterest[.]com/bot[.]html[)].*" |
| 26 | + point = { |
| 27 | + header = "USER-AGENT" |
| 28 | + } |
| 29 | + } |
| 30 | +
|
| 31 | + action { |
| 32 | + type = "equal" |
| 33 | + value = "api" |
| 34 | + point = { |
| 35 | + path = 0 |
| 36 | + } |
| 37 | + } |
| 38 | +
|
| 39 | + action { |
| 40 | + type = "regex" |
| 41 | + value = "v\\d" |
| 42 | + point = { |
| 43 | + path = 1 |
| 44 | + } |
| 45 | + } |
| 46 | +
|
| 47 | + action { |
| 48 | + type = "absent" |
| 49 | + point = { |
| 50 | + action_ext = "" |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +## Argument Reference |
| 57 | + |
| 58 | +* `mode` - (optional) API abuse mode. One of: `enabled`, `disabled`. Default: `enabled`. Changing this value destroys and recreates the rule. |
| 59 | +* `title` - (optional) human-readable rule title. |
| 60 | +* `comment` - (optional) free-text rule comment. Defaults to `Managed by Terraform`. |
| 61 | +* `active` - (optional) whether the rule is active. Defaults to `true`. |
| 62 | +* `client_id` - (optional) ID of the client to apply the rule to. The value is required for [multi-tenant scenarios][2]. |
| 63 | +* `action` - (optional) rule conditions. See the [Action Guide](../guides/action) for full documentation on action conditions, point types, and usage examples. |
| 64 | + |
| 65 | +## Attributes Reference |
| 66 | + |
| 67 | +* `rule_id` - ID of the created rule. |
| 68 | +* `action_id` - the action ID (the conditions to apply on request). |
| 69 | +* `rule_type` - type of the created rule. For `wallarm_rule_api_abuse_mode` this is always `api_abuse_mode`. |
| 70 | + |
| 71 | +## Import |
| 72 | + |
| 73 | +``` |
| 74 | +$ terraform import wallarm_rule_api_abuse_mode.pinterest 6039/563855/11086881 |
| 75 | +``` |
| 76 | + |
| 77 | +* `6039` - Client ID. |
| 78 | +* `563855` - Action ID. |
| 79 | +* `11086881` - Rule ID. |
| 80 | + |
| 81 | +For automated bulk import using the `wallarm_rules` data source, see the [Rules Import Guide](../guides/rules_import). |
| 82 | + |
| 83 | +[1]: https://docs.wallarm.com/api-abuse-prevention/overview/ |
| 84 | +[2]: https://docs.wallarm.com/installation/multi-tenant/overview/ |
0 commit comments