DELAPARRA
Index
Color
NL
Category: Terraform

lifecycle

Explained by Updated

What is lifecycle?

lifecycle: Tunes how Terraform creates, updates and deletes a resource — create_before_destroy, prevent_destroy, ignore_changes. The lifecycle block in Terraform changes how a resource is created, updated and deleted. create_before_destroy builds the replacement before removing the old resource, which avoids downtime for things like certificates or servers behind a load balancer. prevent_destroy makes Terraform refuse any plan that would delete the resource, a valuable safety net for production databases. ignore_changes tells Terraform to ignore certain attributes that are changed outside it, such as tags set by another tool or a scaling count managed by an autoscaler.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about lifecycle

What should you keep in mind with lifecycle?

Use these settings deliberately and add a comment explaining why. ignore_changes in particular can hide real drift, so list specific attributes rather than ignoring everything. A prevent_destroy on your main database costs nothing and prevents one of the worst possible mistakes.

What does an example of lifecycle look like?

lifecycle { create_before_destroy = true prevent_destroy = true ignore_changes = [tags] }

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with L

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.