Firewall rules upgrade·续
Before the APIs sunset date, Cloudflare will internally convert your Firewall Rules API and Filters API calls into the corresponding Rulesets API calls. The converted API calls between the Firewall Rules API/Filters API and the Rulesets API appear in audit logs as generated by Cloudflare and not by the actual user making the requests. There will be a single list of rules for both firewall rules and WAF custom rules.
Some new features of WAF custom rules, like custom responses for blocked requests and the Skip action, are not supported in the Firewall Rules API. To take advantage of these features, Cloudflare recommends that you use the custom rules page in the Cloudflare dashboard or the Rulesets API.
Refer to the WAF documentation for examples of managing WAF custom rules using the Rulesets API.
Relevant changes for Terraform users
The following Terraform resources from the Cloudflare provider are now deprecated:
These resources are no longer supported since 2025-06-15. If you are using these resources to manage your Firewall Rules configuration, you must manually update any Terraform configuration to cloudflare_ruleset ↗︎ resources to prevent any issues.
There will be a single list of rules for both firewall rules and WAF custom rules.
Some new features of WAF custom rules are not supported in the deprecated Terraform resources. To take advantage of these features, Cloudflare recommends that you use the cloudflare_ruleset resource.
Refer to the documentation about Terraform for examples of configuring WAF custom rules using Terraform.
Replace your configuration using cf-terraforming
You can use the cf-terraforming ↗︎ tool to generate the Terraform configuration for your current WAF custom rules (converted by Cloudflare from your firewall rules). Then, import the new resources to Terraform state.
The recommended steps for replacing your firewall rules (and filters) configuration in Terraform with a new ruleset configuration are the following.
- Run the following command to generate all ruleset configurations for a zone:
cf-terraforming generate --zone <ZONE_ID> --resource-type "cloudflare_ruleset"
```
```txt
resource "cloudflare_ruleset" "terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31" {
kind = "zone"
name = "default"
phase = "http_request_firewall_custom"
zone_id = "<ZONE_ID>"
rules {
[...]
}
[...]
}
[...]
```
2. The previous command may return additional ruleset configurations for other Cloudflare products also based on the [Ruleset Engine](https://developers.cloudflare.com/ruleset-engine/). Since you are migrating firewall rules to custom rules, keep only the Terraform resource for the `http_request_firewall_custom` phase and save it to a `.tf` configuration file. You will need the full resource name in the next step.
3. Import the `cloudflare_ruleset` resource you previously identified into Terraform state using the `terraform import` command. For example:
```sh
terraform import cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31 zone/<ZONE_ID>/3c0b456bc2aa443089c5f40f45f51b31
```
```txt
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Importing from ID "zone/<ZONE_ID>/3c0b456bc2aa443089c5f40f45f51b31"...
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Import prepared!
Prepared cloudflare_ruleset for import
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
```
4. Run `terraform plan` to validate that Terraform now checks the state of the new `cloudflare_ruleset` resource, in addition to other existing resources already managed by Terraform. For example:
```sh
terraform plan
```
```txt
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]
[...]
cloudflare_filter.my_filter: Refreshing state... [id=14a2524fd75c419f8d273116815b6349]
cloudflare_firewall_rule.my_firewall_rule: Refreshing state... [id=0580eb5d92e344ddb2374979f74c3ddf]
[...]
```
5. Remove any state related to firewall rules and filters from your Terraform state:
Caution
You must remove firewall rules and filters from Terraform state before deleting their configuration from `.tf` configuration files to prevent issues.
1. Run the following command to find all resources related to firewall rules and filters:
```sh
terraform state list | grep -E '^cloudflare_(filter|firewall_rule)\.'
```
```txt
cloudflare_filter.my_filter
cloudflare_firewall_rule.my_firewall_rule
```
2. Run the `terraform state rm ...` command in dry-run mode to understand the impact of removing those resources without performing any changes:
```sh
terraform state rm -dry-run cloudflare_filter.my_filter cloudflare_firewall_rule.my_firewall_rule
```
```txt
Would remove cloudflare_filter.my_filter
Would remove cloudflare_firewall_rule.my_firewall_rule
```
3. If the impact looks correct, run the same command without the `-dry-run` parameter to actually remove the resources from Terraform state:
```sh
terraform state rm cloudflare_filter.my_filter cloudflare_firewall_rule.my_firewall_rule
```
```txt
Removed cloudflare_filter.my_filter
Removed cloudflare_firewall_rule.my_firewall_rule
Successfully removed 2 resource instance(s).
```
6. After removing firewall rules and filters resources from Terraform state, delete `cloudflare_filter` and `cloudflare_firewall_rule` resources from `.tf` configuration files.
7. Run `terraform plan` to verify that the resources you deleted from configuration files no longer appear. You should not have any pending changes.
```sh
terraform plan
```
```txt
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]
[...]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
```
For details on importing Cloudflare resources to Terraform and using the `cf-terraforming` tool, refer to the following resources:
- [Import Cloudflare resources](https://developers.cloudflare.com/terraform/advanced-topics/import-cloudflare-resources/)
- [`cf-terraforming` GitHub repository ↗︎](https://github.com/cloudflare/cf-terraforming)
## Final remarks
Any unpaused firewall rules with paused [filters](https://developers.cloudflare.com/firewall/api/cf-filters/what-is-a-filter/) will become enabled when converted to custom rules.
Was this helpful?
YesNo
## On this page
[Docs](https://developers.cloudflare.com/)
```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/waf/reference/legacy/firewall-rules-upgrade/#page","headline":"Firewall rules upgrade","description":"Upgrade deprecated Firewall Rules to WAF custom rules.","url":"https://developers.cloudflare.com/waf/reference/legacy/firewall-rules-upgrade/","inLanguage":"en","image":"https://developers.cloudflare.com/waf/reference/legacy/firewall-rules-upgrade/og.png?v=617596f28f797261","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Create rules to inspect and act on incoming HTTP traffic. title: Cloudflare Firewall Rules image: https://developers.cloudflare.com/firewall/og.png?v=57363d946c6a43f9
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/firewall/llms.txt
Use this file to discover all available pages before exploring further.
