Files
opentf/website/docs/language/meta-arguments/lifecycle.mdx
Martin Atkins dc9bec611c website: Reorganize and tidy some lifecycle-related information
Over time the discussion about "lifecycle" blocks in the documentation
became confusing because the docs originally written for managed resource
lifecycle got partially generalized for resources of other modes and for
module calls, even though each of those has a completely different
lifecycle and thus a different set of lifecycle settings.

This is a first pass at trying to reorganize that so that the "lifecycle"
page is really just an index of all of the different kinds of lifecycle
block that exist in the language, while the main documentation for each
use of that block type now belongs with the documentation of the block
it's nested within.

While working on this I also found that there was some duplication inside
the "data sources" page where the same information was described multiple
times, and a few other cases where things had become inconsistent over
time. This also includes a little extra content to try to clarify the
difference between managed, data, and ephemeral resources and to make it
explicit that the "Resources" section is focused only on managed resources
because that is the primary resource mode.

As usual there's lots more that could be done here -- this documentation
has gradually evolved over time and is full of weird quirks due to that
evolution -- but I decided to draw a line here so that the diff wouldn't
get too large.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-17 15:08:14 -07:00

25 lines
1.2 KiB
Plaintext

---
description: >-
The meta-arguments in a lifecycle block allow you to customize resource
behavior.
---
# `lifecycle` Blocks
Several different declaration types in the OpenTofu language support a nested
block named `lifecycle` which includes settings that customize the plan and
apply behavior of the associated object.
Each different type of declaration relates to objects that have a different
lifecycle, and so the arguments available in these blocks are distinct for
each parent block type:
* [`resource` block lifecycle](../../language/resources/behavior.mdx#lifecycle-customizations), for managed resources.
* [`data` block lifecycle](../../language/data-sources/index.mdx#lifecycle-customizations), for data resources.
* [`ephemeral` block lifecycle](../../language/ephemerality/ephemeral-resources.mdx#lifecycle-customizations), for ephemeral resources.
* [`module` block lifecycle](../../language/modules/syntax.mdx#module-lifecycle), for settings that relate to an overall module call instead of the individual resources inside it.
Although all of these features involve a block type named `lifecycle`, the
expected arguments and associated behavior is defined separately for each
context where a block of that type is allowed to appear.