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.
1. Review your configuration history
Before determining how far back to revert, review the versioned history:
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.
2. Examining specific historical changes
Check when the last change was made:
Review the past few changes:
3. Redeploy the previous configuration
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.
i. Revert the branch to the previous commit
Run the following Git command to revert the last commit without rewriting history:
ii. Preview the changes
Run terraform plan
and check the execution plan:
As expected, Terraform is indicating it will remove the two Page Rules created in the previous step.
iii. Apply the changes
The changes look good. Terraform reverts the Cloudflare configuration when you apply the changes:
Two resources were destroyed, as expected, and you have rolled back to the previous version.