Problem
When using Terraform CLI versions v1.1.0 and v1.1.1, some terraform apply runs may not apply the expected planned changes. Instead, the command may incorrectly report success and empty the state file, effectively causing Terraform to forget all existing infrastructure.
Cause
This issue is caused by a bug in Terraform CLI v1.1.0 and v1.1.1 where a failure to construct the apply-time graph results in an empty state file being saved. While configurations that worked correctly in previous versions should not encounter this problem, incorrect future configuration changes could trigger this behavior during the apply step instead of producing an appropriate error.
This bug is described and resolved in GitHub Issue 30199 - Apply graph failure handling.
Solution
To resolve this issue, upgrade the Terraform CLI to version v1.1.2 or later. You can download version 1.1.2 from the releases page.
If you cannot upgrade immediately, you must restore the state file from a backup and downgrade the Terraform CLI to v1.0.11.
Additional Information
- For more details on the fix, refer to the v1.1.2 Release Notes.