gpt4 book ai didi

terraform - 错误刷新状态 : state data in S3 does not have the expected content

转载 作者:行者123 更新时间:2023-12-03 13:54:03 25 4
gpt4 key购买 nike

当我们尝试运行带有远程状态处理的 terraform 脚本时,我们会遇到以下问题:

Error refreshing state: state data in S3 does not have the expected content.This may be caused by unusually long delays in S3 processing a previous stateupdate. Please wait for a minute or two and try again. If this problempersists, and neither S3 nor DynamoDB are experiencing an outage, you may needto manually verify the remote state and update the Digest value stored in theDynamoDB table to the following value

最佳答案

根据您的具体情况,有 3 种可能的解决方法来解决它:
情况1
如果您有 备份 您的 AWS S3 terrform.tfstate您可以恢复状态后端的文件 "s3" {key = "path/to/terraform.tfstate"}到旧版本。重试terraform init并验证它是否运行良好。

案例二
删除 AWS DynamoDB 表中的不同步条目。会有LockID包含状态和预期校验和的表中的条目,您应该删除这些条目,并在重新运行后重新生成 terraform init .
重要注意事项:

  • 在此过程中,您将失去锁状态保护,这会阻止其他人获取锁,并且可能有两个人同时更新破坏您状态的相同资源。
  • 请考虑使用 terraform refresh命令 ( https://www.terraform.io/docs/commands/refresh.html ),用于协调 Terraform 知道的状态(通过其状态文件)与现实世界的基础设施。这可用于检测与上次已知状态的任何漂移,并更新状态文件。
  • 删除 DynamoDB LockID 表条目 -> 屏幕截图:

  • enter image description here

    案例3
    如果在 terraform destroy 之后您已手动删除您的 AWS S3 terraform.tfstate文件,然后可能尝试启动所有 tf​​state 声明资源的新实例,这意味着您正在从头开始工作,您只需更新您的 AWS S3 terrform.tfstate状态后端 key "s3" {key = "path/to/terraform.tfstate"}到一个新的 "s3" {key = "new-path/to/terraform.tfstate"} .重试 terraform init并验证这应该运行良好。此解决方法的局限性在于您还没有真正解决根本原因,您只是使用 S3 tfstate 的新 key 绕过问题。

    关于terraform - 错误刷新状态 : state data in S3 does not have the expected content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57984714/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com