Terraform & IaC
Resource lifecycle
Lifecycle settings control replacement order, destruction guards and ignored attributes, so each setting decides whether a change replaces a live resource safely or is blocked.
What you will be able to do
- Explain how create_before_destroy, prevent_destroy and ignore_changes change a plan.
- Decide when a replacement is safe, and when a lifecycle guard is the right control.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Terraform & IaC
- Drift detectionIntermediate · 4 min
Drift is a difference between Terraform's state and the real infrastructure, and a refresh-only plan shows it without changing anything, though a plan with refresh…
- Plan versus applyIntermediate · 4 min
A plan is a proposal, and a saved plan file holds the reviewed actions that apply performs without a new prompt, which keeps the approval and the change tied together.
- for_each identityIntermediate · 4 min
for_each identifies each instance by its map key or set element, so renaming a key looks like destroying one object and creating another unless the move is recorded.
- count indexingIntermediate · 4 min
count identifies instances by index, so reordering or removing a list item can change which live object each index points to, and the plan can replace them.
- Import existing resourcesAdvanced · 4 min
Import records an existing object in state without changing it, and a clean plan afterwards shows the configuration matches the real object so the team can manage it.
- Module contractsAdvanced · 4 min
A module's input variables and output values form its contract with callers, so renaming an output or removing an input breaks callers even when the module code is…