如何在S3中回滚配置的Terraform状态?

时间:2017-11-08 00:40:42

标签: amazon-s3 terraform

我搞砸了配置的Terraform状态,所以我想用以前的版本替换现有的状态。状态存储在S3中,我正在使用锁表。这是我试过的:

  1. 我从S3下载了旧版本的状态并将其上传到S3,替换了现有版本。 tf plan的结果:

    Error: Error loading state: state data in S3 does not have the expected content.
    
    This may be caused by unusually long delays in S3 processing a previous state
    update.  Please wait for a minute or two and try again. If this problem
    persists, and neither S3 nor DynamoDB are experiencing an outage, you may need
    to manually verify the remote state and update the Digest value stored in the
    DynamoDB table to the following value: XXXXXX
    
  2. 我更新了DynamoDB表中存储的摘要值。 tf plan的结果:

    Acquiring state lock. This may take a few moments...
    
    Error: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed
      status code: 400, request id: XXXXXXX
    Lock Info:
      ID:        XXXXXXX
      Path:      XXXXXX
      Operation: OperationTypePlan
      Who:       XXXXXX
      Version:   0.10.8
      Created:   2017-11-07 23:54:50.505166265 +0000 UTC
      Info:      
    
    
    Terraform acquires a state lock to protect the state from being written
    by multiple users at the same time. Please resolve the issue above and try
    again. For most commands, you can disable locking with the "-lock=false"
    flag, but this is not recommended.
    
  3. 如何将Terraform状态回滚/恢复/恢复/恢复到旧版本?

1 个答案:

答案 0 :(得分:3)

您是否尝试过force unlock命令?在处理锁定问题时,它对我有用。

terraform force-unlock LOCK_ID

lock id是上面输出中的id:

ID:        XXXXXXX