6 – Revert configuration
Sometimes, you may have to roll back configuration changes. For example, you might want to run performance tests on a new configuration or maybe you mistyped an IP address and brought your entire site down.
To revert your configuration, check out the desired branch and ask Terraform to move your Cloudflare settings back in time. If you accidentally brought your site down, consider establishing a good strategy for peer reviewing pull requests rather than merging directly to master
as done in the tutorials for brevity.
Before determining how far back to revert, review your Git history:
git log --oneline
f1a2b3c Step 5 - Add two Page Rulesd4e5f6g Step 4 - Create load balancer (LB) monitor, LB pool, and LBa7b8c9d Step 3 - Enable TLS 1.3, automatic HTTPS rewrites, and strict SSLe1f2g3h Step 2 - Initial Terraform v5 configuration
Another benefit of storing your Cloudflare configuration in Git is that you can see who made the change. You can also see who reviewed and approved the change if you peer-review pull requests.
git log
Check when the last change was made:
git show
This shows the most recent commit and what files changed.
Assume that shortly after you deployed the Page Rules when following the Add exceptions with Page Rules tutorial, you are told the URL is no longer needed, and the security setting and redirect should be dropped.
While you can always edit the config file directly and delete those entries, you can use Git to do that for you.
Use Git to create a revert commit that undoes the Page Rules changes:
git revert HEAD
Git will open your default editor with a commit message. Save and close to accept the default message, or customize it:
Revert "Add Page Rules for security and redirects"
This reverts commit f1a2b3c4d5e6f7a8b9c0d1e2f3g4h5i6j7k8l9m0.
Check what Terraform will do with the reverted configuration:
terraform plan
Expected output:
Plan: 0 to add, 0 to change, 2 to destroy.
Terraform will perform the following actions:
# cloudflare_page_rule.expensive_endpoint_security will be destroyed # cloudflare_page_rule.legacy_redirect will be destroyed
As expected, Terraform will remove the two Page Rules that were added in tutorial 5.
Apply the changes to remove the Page Rules from your Cloudflare zone:
terraform apply --auto-approve
cloudflare_page_rule.expensive_endpoint_security: Destroying...cloudflare_page_rule.legacy_redirect: Destroying...cloudflare_page_rule.expensive_endpoint_security: Destruction complete after 1scloudflare_page_rule.legacy_redirect: Destruction complete after 1s
Apply complete! Resources: 0 added, 0 changed, 2 destroyed.
Two resources were destroyed, as expected, and you have rolled back to the previous version.
Test that the Page Rules are no longer active:
# This should now return 404 (no redirect)curl -I https://www.example.com/old-location.php
# This should return normal response (no Under Attack mode)curl -I https://www.example.com/expensive-db-call
Your configuration has been successfully reverted. The Page Rules are removed, and your zone settings are back to the previous state. Git's version control ensures you can always recover or revert changes safely.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark