首页 > 解决方案 > terraform statefile 已锁定如何解锁

问题描述

我使用terraform了状态列表,但它显示由于文件被锁定而无法读取tfstate我如何解锁并获取部署资源的状态?

Error: Error loading state: Failed to read state file: The state file could not be read: read terraform.tfstate: The process cannot access the file because another process has locked a portion of the file.

标签: terraform

解决方案


您可以使用force-unlock命令手动解锁状态:

terraform force-unlock LOCK_ID

锁 ID 通常显示在错误消息中。

如果您的状态是本地的并且被本地进程锁定,它可能不起作用。如果是这种情况,请尝试终止该进程并重试。


推荐阅读