DDoS managed rulesets are always enabled. Depending on your Cloudflare services, you may be able to adjust their behavior.
For more information on DDoS managed rulesets, refer to Managed rulesets in the Cloudflare DDoS Protection documentation. For more information on deploying and configuring rulesets using the Rulesets API, refer to Work with managed rulesets in the Ruleset Engine documentation.
Before you start
Obtain the necessary account, zone, and managed ruleset IDs
The Terraform configurations provided in this page need the zone ID (or account ID) of the zone/account where you will deploy the managed rulesets.
To retrieve the list of accounts you have access to, including their IDs, use the List accounts operation.
To retrieve the list of zones you have access to, including their IDs, use the List zones operation.
The deployment of managed rulesets via Terraform requires that you use the ruleset IDs. To find the IDs of managed rulesets, use the List account rulesets operation. The response will include the description and IDs of existing managed rulesets.
(Optional) Delete existing rulesets to start from scratch
Terraform assumes that it has complete control over account and zone rulesets. If you already have rulesets configured in your account or zone, do one of the following:
Import existing rulesets to Terraform using the cf-terraforming tool. Recent versions of the tool can generate resource definitions for existing rulesets and import their configuration to Terraform state.
Start from scratch by deleting existing rulesets (account and zone rulesets with "kind": "root" and "kind": "zone", respectively) and then defining your rulesets configuration in Terraform.
Example: Configure HTTP DDoS Attack Protection
This example configures the HTTP DDoS Attack Protection managed ruleset for a zone using Terraform, changing the sensitivity level of rule with ID fdfdac75430c4c47a959592f0aa5e68a to low.
This example configures the Network-layer DDoS Attack Protection managed ruleset for an account using Terraform, changing the sensitivity level of rule with ID 599dab0942ff4898ac1b7797e954e98b to low using an override.
Use case: Mitigate large HTTP DDoS attacks and monitor flagged traffic
In the following example, a customer is concerned about false positives, but wants to get protection against large HTTP DDoS attacks. The two rules, containing two overrides each, in their HTTP DDoS protection configuration will have the following behavior:
Mitigate any large HTTP DDoS attacks by configuring a rule with a Lowsensitivity level and a Block action.
Monitor traffic being flagged by the DDoS protection system by configuring a rule with the default sensitivity level (High) and a Log action.
The order of the rules is important: the rule with the highest sensitivity level must come after the rule with the lowest sensitivity level, otherwise it will never be evaluated.
Was this helpful?
What did you like?
What went wrong?
Thank you for helping improve Cloudflare's documentation!