错误锁定状态:错误获取状态锁定:状态Blob已被锁定

时间:2020-11-05 02:33:43

标签: terraform terraform-provider-azure

尝试执行任何操作时出现此错误:

Error locking state: Error acquiring the state lock: state blob is already locked

我如何列出当前拥有锁的人以及该锁已获得多长时间?

1 个答案:

答案 0 :(得分:1)

取决于用于状态锁定的机制。

您可以在配置中看到它(例如,当用作文件名时在terraform.tf中。)

terraform {
  required_version = "0.13.4"
  backend "s3" {
    bucket         = "my.state.bucket.for.terraform"
    key            = "infra/my.tfstate"
    region         = "eu-central-1"
    encrypt        = true
    dynamodb_table = "my.locking.table.in.dynamo"
  }
}

如果使用dynamobdb(在AWS上),只需检查表即可。 PostgreSQL或其他类似的东西。

要解决此问题,您可以从客户端释放状态:

terraform force-unlock <ID_OF_LOCK_SHOWN_IN_ERROR>