Backup and restores of TF managed resources

When you are building infrastructure with Terraform. Its building the infrastructure using API. This transaction of state after the calls have been made are stored in a state file. You specify that your storing in s3. S3 stores an object in three physical locations which had a very high resilience to failure. If your worried about your state files having issues. I suggest you do two things with s3. Turn on versioning and also use replication. The version will change with each state change the replica can be stored in the same or different region or even a separate account. I recommend the latter. Now dealing with your infrastructure issues. You ideally want to model you infrastructure as something that can withstand a complete failure. So the easy path with terraform is to build out your infrastructure as mutable. So you design with either additional resources in mind or you design the build to move easily by tearing down and rebuilding. Ideally you keep the data being used by the application in a separate terraform state and reference it in your application build. Should you have a failure on a component you can taint the resources affected and terraform will rebuild these sections of resources. If you need to build out entirely new segment of IaC in a new region ideally your TF will require a minor change and assuming all services are available should be trivial assuming your data is HA and also DR ready.

Ideally you keep your instance stateless and it serves from something else which means you can keep your instance up to date. If you are want to keep the instance and it needs to be patches etc. you need to import it into your state. You could do this as part of a pipeline or lambda potentially.

Hope this helps.

/r/Terraform Thread