AWS TerraForm DynamoDB还原场景

发布于 2025-02-10 10:57:50 字数 286 浏览 2 评论 0原文

我将从备份还原DynamoDB表,并且由于AWS不支持将备份还原到同一表,我将进行以下操作:

  1. 还原表A的备份到新表B
  2. 备份表B备份表B
  3. 删除表A
  4. 还还原表B的备份作为表A

我正在使用Terraform来管理资源。我的问题是:

  1. 这个会破坏Terraform资源链接/差异,并使下一个部署失败。
  2. 表A是否可以在仍在恢复的同时接受请求(步骤4)?
  3. 还可以恢复DynamoDB表吗?

I am going to restore a dynamodb table from backup and as AWS does not support restoring backups to the same table I will do the following:

  1. Restore table A's backup to a new table B
  2. Backup table B
  3. Delete table A
  4. Restore table B's backup as table A

I am using Terraform to manage resources. My questions are:

  1. Will this break Terraform resource link/diff and make next deploy fail.
  2. Will table A be ready to accept request while still being restored (step 4)?
  3. Are there other best practices to restore a DynamoDB table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀟灑尐姊 2025-02-17 10:57:50

正如马克·B(Mark B)所写的那样,您将当然需要将已还原的表导入状态文件。在此之前,您需要删除旧的。

  1. 时间点,并确保使用相同的kms键,使用名称为“ Restored_table_name
  2. 通过控制台恢复到您想要的
terraform state pull > backup_state_file_timestamp.json
terraform state rm aws_dynamodb_table.resource_name
  1. ” 进入Terraform(假设您命名为a)
terraform import aws_dynamodb_table.resource_name restored_table_name

在TF代码中您将引用名称,如下所示,因此新表名称并不重要(除非您将其核对在某个地方)

aws_dynamodb_table.resource_name.restored_table_name

As Mark B wrote, you will certainly need to import the restored table to the state file. And before that you need to remove the old one.

  1. Restore through the console to the point in time you want and make sure to use the same KMS key, using as name "restored_table_name" ..
  2. Take a backup of your state file
terraform state pull > backup_state_file_timestamp.json
  1. Remove the old table from your terraform state file
terraform state rm aws_dynamodb_table.resource_name
  1. Import the manually restored tabke into terraform (assuming you named it A)
terraform import aws_dynamodb_table.resource_name restored_table_name

In the tf code you will be referencing the name as shown below, hence the new table name doesnt really matter (unless you hardocded it somewhere)

aws_dynamodb_table.resource_name.restored_table_name
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文