โ† Terraform Associate Exam Practice learning path
Terraform Associate Exam Practice ยท Module 8 of 10

Lifecycle and resource behaviour

Controlling create, update and replace.

๐Ÿ“– Key ideas

  1. The lifecycle block supports create_before_destroy, prevent_destroy, ignore_changes and replace_triggered_by.
  2. terraform apply -replace=ADDRESS forces recreation (replacing the older taint command).
  3. Provisioners (local-exec, remote-exec) are a last resort; prefer native features or config tools.
  4. terraform refresh behaviour is now part of plan and apply (-refresh-only to review drift).
  5. 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