Files
opentf/website/docs/language/resources/index.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

46 lines
2.0 KiB
Plaintext

---
description: >-
Resources describe infrastructure objects in OpenTofu configurations. Find
documentation for resource syntax, behavior, and meta-arguments.
---
# Resources
_Resources_ are the most important element in the OpenTofu language.
Each resource block describes one or more infrastructure objects, such
as virtual networks, compute instances, or higher-level components such
as DNS records.
This section discusses the main kind of resource, known as a "managed resource",
which represents an infrastructure object managed by OpenTofu.
- [Resource Blocks](../../language/resources/syntax.mdx) documents
the syntax for declaring resources.
- [Resource Behavior](../../language/resources/behavior.mdx) explains in
more detail how OpenTofu handles resource declarations when applying a
configuration.
- The Meta-Arguments section documents special arguments that can be used with
any managed resource type, including
[`depends_on`](../../language/meta-arguments/depends_on.mdx),
[`count`](../../language/meta-arguments/count.mdx),
[`for_each`](../../language/meta-arguments/for_each.mdx),
[`provider`](../../language/meta-arguments/resource-provider.mdx),
and [`lifecycle`](behavior.mdx#lifecycle-customizations).
- [Provisioners](provisioners/syntax.mdx) are post-creation actions for a
resource using the `provisioner` and `connection` blocks. Since provisioners
are non-declarative and potentially unpredictable, we strongly recommend that
you treat them as a last resort.
There are two other kinds of resources that play different roles within an
OpenTofu configuration:
- [Data resources](../../language/data-sources/index.mdx) declare that a
configuration depends on information read from a data source outside of the
configuration.
- [Ephemeral resources](../../language/ephemerality/ephemeral-resources.mdx)
declare transient objects that are opened only for the duration of a single
OpenTofu phase, such as temporary session credentials.