โ Terraform Associate Exam Practice learning pathTerraform Associate Exam Practice ยท Module 8 of 10
Lifecycle and resource behaviour
Controlling create, update and replace.
๐ Key ideas
- The lifecycle block supports create_before_destroy, prevent_destroy, ignore_changes and replace_triggered_by.
- terraform apply -replace=ADDRESS forces recreation (replacing the older taint command).
- Provisioners (local-exec, remote-exec) are a last resort; prefer native features or config tools.
- terraform refresh behaviour is now part of plan and apply (-refresh-only to review drift).
- Check and precondition/postcondition blocks validate assumptions.
๐ก Real-life example: Like moving shops: open the new shop before closing the old one so customers are never turned away.
create_before_destroyCreate replacement before deleting old
prevent_destroyBlock accidental deletion
ignore_changesIgnore drift in selected attributes
-replaceForce a resource to be recreated