The usual way to represent “rolling back†in Terraform is to put your configuration in version control and commit before each change, and then you can use your version control system’s features to revert to an older configuration if needed. You always need to recommit the previous version code for it to be the new version in the version control system.
Not all changes can be rolled back purely by reverting a version control system change though. For example, if you added a new provider block and resources for that provider all in one commit and then applied the result, in order to rollback, you would need to change the configuration to still include the provider block but not include any of the resource blocks, so you would need to adjust the configuration during the revert. Terraform will then use the remaining provider block to configure the provider to run the destroy actions, after which you can finally remove the provider block too.
If the state file gets corrupted from the latest terraform run, then you can use terraform enterprise and its features of state rollback to go to the previous latest state which was working fine and was in a good state. This is possible in the enterprise version because every state change is versioned there.
Posted Date:- 2021-11-23 08:34:07
How to ignore duplicate resource error during terraform apply?
Tell me the reasons to choose Terraform for DevOps?
How would you recover from a failed apply in Terraform?
How do you move the state from one source to another?
Does the taint command modify the infrastructure?
How do you inspect the current state of the infrastructure applied in terraform?
Is there a way to bulk import the state of the current cloud subscription into Terraform state?
How do you recover from a failed apply, where some resources were provisions, but others were not?
Can I add policies to the open-source or pro version of Terraform enterprise?
How can you handle CLI authentication on terraform cloud?
Which command is used to destroy Terraform-managed infrastructure?
Tell Us About Some of the Terraform CLI Commands and their Functions?
How to Ignore the Error Duplicate Resource During Terraform Apply?
How will you check whether your POVRay install is ok with the terraform?
Explain State File Locking in the context of Terraform.
Can I use Terraform for on-premises infrastructure?
What if I encounter a serious error and want to rollback?
Can I add policies to the open-source or Pro version of Terraform Enterprise?
What do you know about Terragrunt? What are its uses?
Are themes supported by terraforming?
What are the new factors in the latest v1.24.0 & v1.25.0 Terraform Azure Provider?
How to Store Sensitive Data in Terraform?
Why write tests for Sentinel policies?
What is Private Module Registry?
How can I check if the POVRay install is compatible with Terraform?
Why does POVRay render fields and does not display sometimes?
What are the different behaviors of Terraform plugins during discovery?
Do you know about the new factors in the latest v1.24.0 and v1.25.0 Terraform Azure Provider?
How will you control and handle rollbacks when something goes wrong?