バックエンドがS3で、ロック管理でDynamoDBを使ってるのが前提で、stateのkeyを変更したかった。 でもkeyを変更すると同一リソースを管理するstateが二重に存在することになってplan結果がaddとdestroyが混在する形となったので、key変更前のS3のtfstateファイルを削除した。 そうすると、以下エラーでterrform initで失敗した。
The checksum calculated for the state stored in S3 does not match the checksum stored in DynamoDB. Bucket: xxxxxxxxxxxxxxxxxxxxxxx Key: xxxxxxxxxxxxxxxxxxxxxxx.tfstate Calculated checksum: Stored checksum: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 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 remove the Digest value stored in the DynamoDB table Error: Terraform exited with code 1. Error: Process completed with exit code 1.
数分置いてterraform initを再実行しても変わらないので、DynamoDBのvalueを消した。 github.com