Terraform dice que el recurso ya existe: recupera la propiedad del state
El problema no es que Terraform no pueda crear el recurso Un AlreadyExists , AlreadyAssociated o conflicto de creación suele disparar la reacción equivocada: borrar algo y volver a ejecutar apply . No lo hagas. Terraform no está diciendo que la infraestructura esté necesariamente mal; está diciendo que intenta crear algo que el proveedor ya conoce, mientras su state no lo considera bajo su…
Terraform informs users that a resource already exists, indicating a property mismatch between its state and the remote object. This problem occurs when Terraform cannot create a resource that already exists in the provider, yet Terraform does not yet manage it in its state. The recommended approach is not to delete and reapply, but to understand which object truly belongs to Terraform, who should manage it, and what the current state represents.
Terraform works with two sources of truth: the configuration defines the desired state, and the state records the remote objects Terraform manages for each resource. If an object exists but lacks ownership in the state, Terraform plans a create. The provider rejects creation because the object or exclusive relationship already exists.
In summary, the recovery cycle consists of four steps: the remote resource exists, Terraform plans to create it, import establishes ownership, and a revised plan reconciles Terraform's actions. Drift and real conflict are not the same; the error indicates ownership breach rather than drift. First, freeze concurrent changes and read the error for clues.
Check if the object exists in the state list, then compare its attributes with the configuration and provider APIs. Confirm the configuration's intent, inspect the remote with read-only queries, and use import to declare ownership instead of repairing infrastructure. After import, run a saved plan to review changes and ensure they align with the recovery goal.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.