Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

The apply we interrupted and the resources state never heard about

说明与用途

中断的 Terraform 应用导致资源在云中存在但未记录在状态中,产生重复和额外费用。通过动态超时、取消安全处理和中断后刷新/差异/导入流程解决问题。

问题

An interrupted Terraform apply left resources partially created, causing orphan resources and state inconsistencies, leading to unexpected costs and failed subsequent runs.

结果

The new process prevents orphan resources, eliminates duplicate NAT gateways, and keeps costs predictable by ensuring state reflects reality after interruptions.

工作流

  • 1. Run Terraform apply with dynamic timeout and cancellation‑safe step marking.
  • 2. If apply is interrupted, run terraform refresh to sync state with actual resources.
  • 3. Execute terraform plan to identify differences between state and real resources.
  • 4. Import any existing resources missing from state using terraform import.
  • 5. Re‑run terraform apply to apply remaining changes.
  • 6. Weekly: run a sweep script that lists resources with the workspace tag and compares them against state to detect forgotten resources.

证据

Terraform does not roll anything back when you kill it. Resources that were created before the process died exist in the cloud; whether they exist in state depends on whether the state write completed.

来源

We also run a weekly sweep that lists resources carrying our workspace tag and compares them against state, which is how you find things Terraform has forgotten it owns.

来源

  • 记录日期: 2026-09-15T22:15:52.830Z