Overview - Create_before_destroy lifecycle rule
What is it?
The create_before_destroy lifecycle rule in Terraform tells the system to make a new resource first before removing the old one. This helps avoid downtime by ensuring the new resource is ready before the old one goes away. It is used when replacing resources that cannot be offline without causing problems. This rule changes the order Terraform follows when updating infrastructure.
Why it matters
Without create_before_destroy, Terraform deletes the old resource before creating the new one, which can cause service interruptions or data loss. For example, if a server or database is destroyed before the new one is ready, users may experience downtime. This rule ensures smooth transitions and continuous availability, which is critical for real-world systems that must stay online.
Where it fits
Before learning this, you should understand basic Terraform resource creation and destruction. After this, you can learn about other lifecycle rules like prevent_destroy and ignore_changes, and how to manage complex infrastructure updates safely.