lifecycle block

A block inside a resource that changes how Terraform replaces or protects it, with settings such as create_before_destroy, prevent_destroy and ignore_changes.

In more detail

create_before_destroy builds the new object before removing the old one, avoiding a gap. ignore_changes stops Terraform undoing edits made outside it to chosen attributes, and replace_triggered_by replaces a resource when another one changes. Keep these rules narrow, because each one hides something from normal planning.

Example

lifecycle {
  create_before_destroy = true
  ignore_changes        = [tags]
}

Related terms

Taught in

References

Certification courses