Rate limiting (previous version) upgrade·续
Relevant changes for Terraform users
The cloudflare_rate_limit Terraform resource is deprecated. The resource is no longer supported since 2025-06-15. You must manually update your rate limiting configuration in Terraform from cloudflare_rate_limit ↗︎ resources to cloudflare_ruleset ↗︎ resources to prevent any issues.
The new rate limiting rules are based on the Ruleset Engine. To configure these rate limiting rules with Terraform you must use the cloudflare_ruleset Terraform resource.
The cloudflare_ruleset ↗︎ Terraform resource is the only resource that allows you to create, edit, and delete any rate limiting rule, regardless of the implementation version where you created the rule. The cloudflare_rate_limit Terraform resource will only work with rate limiting rules created in the previous version that you have not edited in the dashboard or modified through the new API/Terraform resource since they were upgraded to the new version.
Until the sunset date for the cloudflare_rate_limit Terraform resource, you can use this resource to create, edit, and delete rate limiting rules created in the previous version (which Cloudflare upgraded to the new version). However, if you start using the cloudflare_ruleset Terraform resource to manage a rule created in the previous version, or if you edit such a rule in the Cloudflare dashboard – including changing the rule order – you will no longer be able to manage this rule (upgraded from the previous version and then updated using the new resource) using the old Terraform resource. In this case, you will need to completely switch to the cloudflare_ruleset Terraform resource for managing this specific rule.
Refer to the Terraform documentation for examples of configuring the new rate limiting rules using Terraform.
Replace your configuration with cf-terraforming
You can use the cf-terraforming ↗︎ tool to generate your new Terraform configuration for rate limiting rules created in the previous version. Then, you can import the new resources to Terraform state.
The recommended steps for replacing your old rate limiting 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"
```
```tf
resource "cloudflare_ruleset" "terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31" {
kind = "zone"
name = "default"
phase = "http_ratelimit"
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 updating your rate limiting rules configuration, keep only the Terraform resource for the `http_ratelimit` 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_rate_limit.my_rate_limiting_rules: Refreshing state... [id=0580eb5d92e344ddb2374979f74c3ddf]
[...]
```
5. Remove any state related to rate limiting rules configured through the old `cloudflare_rate_limit` resource from your Terraform state:
Important
You must remove rate limiting rules configured through the `cloudflare_rate_limit` resource 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 rate limiting rules (previous version):
```sh
terraform state list | grep -E '^cloudflare_rate_limit\.'
```
```txt
cloudflare_rate_limit.my_rate_limiting_rules
```
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_rate_limit.my_rate_limiting_rules
```
```txt
Would remove cloudflare_rate_limit.my_rate_limiting_rules
```
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_rate_limit.my_rate_limiting_rules
```
```txt
Removed cloudflare_rate_limit.my_rate_limiting_rules
Successfully removed 1 resource instance(s).
```
6. After removing `cloudflare_rate_limit` resources from Terraform state, delete all these 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)
## More resources
For more information on the new rate limiting implementation, including the available features in each Cloudflare plan, refer to [Rate limiting rules](https://developers.cloudflare.com/waf/rate-limiting-rules/).
Cloudflare also offers an Advanced version of Rate Limiting, which is available to Enterprise customers. For more information, refer to the [Introducing Advanced Rate Limiting ↗︎](https://blog.cloudflare.com/advanced-rate-limiting/) blog post.
To learn more about what you can do with the new rate limiting, refer to [Rate limiting best practices](https://developers.cloudflare.com/waf/rate-limiting-rules/best-practices/).
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/old-rate-limiting/upgrade/#page","headline":"Rate limiting (previous version) upgrade","description":"Guide on upgrading rate limiting rules from the previous version to the new version.","url":"https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/upgrade/","inLanguage":"en","image":"https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/upgrade/og.png?v=cccfe52c2c659055","dateModified":"2026-04-21","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: Documentation for the previous version of WAF managed rules. title: WAF managed rules (previous version) image: https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/og.png?v=09af6c96f9b66628
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/waf/llms.txt
Use this file to discover all available pages before exploring further.
