terraform 还原 RDS 备份

terraform restore an RDS backup

我们使用 Terraform 在 AWS 中创建所有资源。如果一切按计划进行,那将很方便。但是,我们确实必须考虑出现问题的时间。我们有一个问题是 RDS 实例。它由 Terraform 创建和跟踪。在系统崩溃的情况下,我们需要恢复备份。我认为 AWS 每天都会自动进行备份,因此我们无需担心备份问题。但我不确定 terraform 是否可以很好地处理恢复。如果我们手动恢复备份,terraform 将如何跟踪它?它甚至可行吗?还是我们应该让 terraform 进行恢复?代码是什么样子的?

我相信你可以使用 restore_to_point_in_time (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#restore_to_point_in_time-argument-reference) ,但我没有亲自尝试过:

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
  }
}