We use terraform to create all our resources in AWS. It is convenient if everything goes as planned. However, we do have to consider times when things go wrong. One question we have is the RDS instance. It is created and tracked by terraform. In the case of a system crash, we need to restore the backup. I think AWS automatically makes backups every day so we do not need to worry about the backup. But I am not sure if terraform can handle the restore well. If we manually restore a backup, how would terraform be able to track it? Is it even doable? Or should we let terraform do the restore? How does the code look like?
I believe you can use restore_to_point_in_time
(https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#restore_to_point_in_time-argument-reference) for this, but I have not personally tried it:
resource "aws_rds_cluster" "example-clone" {
# ... other configuration ...
restore_to_point_in_time {
source_cluster_identifier = "example"
restore_type = "copy-on-write"
use_latest_restorable_time = true
}
}