I've messed up the Terraform state of a config, so I'd like to replace the existing state with a previous version. The state is stored in S3, and I'm using a lock table. Here's what I tried:
I downloaded an old version of the state from S3 and uploaded it to S3, replacing the existing version. Result of
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: XXXXXXI updated the digest value stored in the DynamoDB table. Result of
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.
How can I roll back/revert/recover/restore the Terraform state to an older version?