From ea8d71f824996676476f15610a7c85347a05f6a2 Mon Sep 17 00:00:00 2001 From: trujillo-adam Date: Fri, 10 Oct 2025 08:45:17 -0700 Subject: [PATCH 1/4] first commit - draft clarification on M-A docs --- .../docs/language/meta-arguments.mdx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx b/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx index 682a8ef7ec..d97bd2341b 100644 --- a/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx +++ b/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx @@ -185,17 +185,26 @@ Terraform performs the following operations when you apply a configuration: 1. Creates resources defined in the configuration that are not associated with a real infrastructure object in the state. 1. Destroys resources that exist in the state but not in the configuration. 1. Updates in-place resources whose arguments have changed. -1. Destroys and re-create resources whose arguments have changed but that Terraform cannot update in-place because of remote API limitations. +1. Destroys and re-creates resources whose arguments have changed but that Terraform cannot update in-place because of remote API limitations. 1. Invokes actions that are configured to run during an apply operation. -The `lifecycle` block accepts a rule that customizes how Terraform performs the lifecycle stages for each resource. Support for each `lifecycle` rule varies across Terraform configuration blocks. Refer to the reference documentation for the Terraform block you are adding to your configuration for details. The following table describes support for each `lifecycle` rule: +The `lifecycle` block accepts a rule that customizes how Terraform performs the lifecycle stages for each resource. Support for each `lifecycle` rule varies across Terraform configuration blocks. Refer to the reference documentation for the Terraform block you are adding to your configuration for details. +### State + +Except for `create_before_destroy`, Terraform does not explicitly record a resource's `lifecycle` rule to state. As a result, Terraform destroys the actual infrastructure during an apply operation if you remove the resource's configuration, even if `prevent_destroy` is enabled. Refer to [Remove a resource from state](/terraform/language/state/remove) for instructions on how to remove a resource from state without destroying the actual resource. + +Terraform records the results of `precondition` and `postcondition` checks to state, but not the contents of the checks. Terraform may also record values in `lifecycle` rules as resource dependencies. + +### Rules + +The following table describes support for each `lifecycle` rule: | Rule | Description | Terraform block | | --- | --- | --- | | `action_trigger` | Terraform runs the configured action when the specified conditions are met. Refer to [Invoke an action](/terraform/language/invoke-actions) for details. | `resource` | | `create_before_destroy` | Terraform creates a replacement resource before destroying the current resource. | `resource` | -| `prevent_destroy` | Terraform rejects operations to destroy the resource and returns an error. | `resource` | +| `prevent_destroy` | Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying a resource if you remove its configuration. Refer to [Remove a resource from state](/terraform/language/state/remove) for instructions on how to remove a resource from state without destroying the actual resource. | `resource` | | `ignore_changes` | Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. | `resource` | | `replace_triggered_by` | Terraform replaces the resource when any of the referenced resources or specified attributes change. | `resource` | | `precondition` | Specifies a condition that Terraform evaluates before creating the resource. | `data`, `ephemeral`, `resource` | From 8b2a1af9c50483096b045f03e416aba5f9b961f9 Mon Sep 17 00:00:00 2001 From: trujillo-adam Date: Fri, 10 Oct 2025 11:07:47 -0700 Subject: [PATCH 2/4] add info to prevent_destroy in resource block --- .../terraform/v1.14.x (beta)/docs/language/block/resource.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx b/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx index 472d5adcf5..7d58afe16b 100644 --- a/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx +++ b/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx @@ -330,7 +330,7 @@ You can specify the following lifecycle rules to manage how Terraform performs o - [`action_trigger](#action_trigger)`: Specifies a set of arguments that determine which events trigger one or more provider actions, under which conditions the action runs, and which actions Terraform invokes. - [`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource. -- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. +- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, tefer to [Remove a resource from state](/terraform/language/state/remove). - [`ignore_changes`](#ignore_changes): Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. - [`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change. - [`precondition`](#precondition): Specifies a condition that Terraform evaluates before creating the resource. Refer to [Validate your configuration](/terraform/language/validate) for more information. From 0e9d3194675c9245fb7e9a14b430ad711368d0b9 Mon Sep 17 00:00:00 2001 From: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> Date: Fri, 10 Oct 2025 11:41:14 -0700 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Brian McClain --- .../terraform/v1.14.x (beta)/docs/language/block/resource.mdx | 2 +- .../terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx b/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx index 7d58afe16b..72930ed7a1 100644 --- a/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx +++ b/content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx @@ -330,7 +330,7 @@ You can specify the following lifecycle rules to manage how Terraform performs o - [`action_trigger](#action_trigger)`: Specifies a set of arguments that determine which events trigger one or more provider actions, under which conditions the action runs, and which actions Terraform invokes. - [`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource. -- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, tefer to [Remove a resource from state](/terraform/language/state/remove). +- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, refer to [Remove a resource from state](/terraform/language/state/remove). - [`ignore_changes`](#ignore_changes): Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. - [`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change. - [`precondition`](#precondition): Specifies a condition that Terraform evaluates before creating the resource. Refer to [Validate your configuration](/terraform/language/validate) for more information. diff --git a/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx b/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx index d97bd2341b..ba8a5bc6a6 100644 --- a/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx +++ b/content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx @@ -194,7 +194,7 @@ The `lifecycle` block accepts a rule that customizes how Terraform performs the Except for `create_before_destroy`, Terraform does not explicitly record a resource's `lifecycle` rule to state. As a result, Terraform destroys the actual infrastructure during an apply operation if you remove the resource's configuration, even if `prevent_destroy` is enabled. Refer to [Remove a resource from state](/terraform/language/state/remove) for instructions on how to remove a resource from state without destroying the actual resource. -Terraform records the results of `precondition` and `postcondition` checks to state, but not the contents of the checks. Terraform may also record values in `lifecycle` rules as resource dependencies. +Terraform records the results of `precondition` and `postcondition` checks to state, but not the contents of the checks. ### Rules From 5d9b9e0c93ad6564e3d436d08e741094c0054c1a Mon Sep 17 00:00:00 2001 From: trujillo-adam Date: Fri, 10 Oct 2025 13:36:42 -0700 Subject: [PATCH 4/4] added info to other versions --- content/terraform/v1.12.x/docs/language/block/resource.mdx | 6 ++++-- content/terraform/v1.12.x/docs/language/meta-arguments.mdx | 2 +- content/terraform/v1.13.x/docs/language/block/resource.mdx | 6 ++++-- content/terraform/v1.13.x/docs/language/meta-arguments.mdx | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/content/terraform/v1.12.x/docs/language/block/resource.mdx b/content/terraform/v1.12.x/docs/language/block/resource.mdx index 95194d4876..f0cde37be8 100644 --- a/content/terraform/v1.12.x/docs/language/block/resource.mdx +++ b/content/terraform/v1.12.x/docs/language/block/resource.mdx @@ -315,7 +315,7 @@ resource { You can specify the following lifecycle rules to manage how Terraform performs operations on the resource: - [`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource. -- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. +- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, refer to [Remove a resource from state](/terraform/language/state/remove). - [`ignore_changes`](#ignore_changes): Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. - [`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change. - [`precondition`](#precondition): Specifies a condition that Terraform evaluates before creating the resource. Refer to [Validate your configuration](/terraform/language/validate) for more information. @@ -369,7 +369,9 @@ resource { Use this argument to prevent team members from accidentally replacing critical infrastructure, such as database instances. -When the `prevent_destroy` argument is set, you must either remove the resource from the configuration or change the `prevent_destroy` argument to `false` to destroy it. Use this argument with caution. The `prevent_destroy` argument can make applying resource changes or destroying resources more complex. +When `prevent_destroy` is enabled, you must either remove the resource from the configuration or change the `prevent_destroy` argument to `false` to destroy it. Use this argument with caution. The `prevent_destroy` argument can make applying resource changes or destroying resources more complex. + +This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, refer to [Remove a resource from state](/terraform/language/state/remove). #### Summary diff --git a/content/terraform/v1.12.x/docs/language/meta-arguments.mdx b/content/terraform/v1.12.x/docs/language/meta-arguments.mdx index 89298d3f65..6a5f3fbf5f 100644 --- a/content/terraform/v1.12.x/docs/language/meta-arguments.mdx +++ b/content/terraform/v1.12.x/docs/language/meta-arguments.mdx @@ -180,7 +180,7 @@ The `lifecycle` block accepts a rule that customizes how Terraform performs the | Rule | Description | Terraform block | | --- | --- | --- | | `create_before_destroy` | Terraform creates a replacement resource before destroying the current resource. | `resource` | -| `prevent_destroy` | Terraform rejects operations to destroy the resource and returns an error. | `resource` | +| `prevent_destroy` | Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, refer to [Remove a resource from state](/terraform/language/state/remove). | `resource` | | `ignore_changes` | Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. | `resource` | | `replace_triggered_by` | Terraform replaces the resource when any of the referenced resources or specified attributes change. | `resource` | | `precondition` | Specifies a condition that Terraform evaluates before creating the resource. | `data`, `ephemeral`, `resource` | diff --git a/content/terraform/v1.13.x/docs/language/block/resource.mdx b/content/terraform/v1.13.x/docs/language/block/resource.mdx index 61c8f0b960..7b83432241 100644 --- a/content/terraform/v1.13.x/docs/language/block/resource.mdx +++ b/content/terraform/v1.13.x/docs/language/block/resource.mdx @@ -321,7 +321,7 @@ resource { You can specify the following lifecycle rules to manage how Terraform performs operations on the resource: - [`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource. -- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. +- [`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, refer to [Remove a resource from state](/terraform/language/state/remove). - [`ignore_changes`](#ignore_changes): Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. - [`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change. - [`precondition`](#precondition): Specifies a condition that Terraform evaluates before creating the resource. Refer to [Validate your configuration](/terraform/language/validate) for more information. @@ -375,7 +375,9 @@ resource { Use this argument to prevent team members from accidentally replacing critical infrastructure, such as database instances. -When the `prevent_destroy` argument is set, you must either remove the resource from the configuration or change the `prevent_destroy` argument to `false` to destroy it. Use this argument with caution. The `prevent_destroy` argument can make applying resource changes or destroying resources more complex. +When `prevent_destroy` is enabled, you must either remove the resource from the configuration or change the `prevent_destroy` argument to `false` to destroy it. Use this argument with caution. The `prevent_destroy` argument can make applying resource changes or destroying resources more complex. + +This rule doesn't prevent Terraform from destroying the resource if you remove the resource configuration. For instructions on how to remove a resource from state without destroying the actual resource, refer to [Remove a resource from state](/terraform/language/state/remove). #### Summary diff --git a/content/terraform/v1.13.x/docs/language/meta-arguments.mdx b/content/terraform/v1.13.x/docs/language/meta-arguments.mdx index d66d68ffeb..c6dbb8a24c 100644 --- a/content/terraform/v1.13.x/docs/language/meta-arguments.mdx +++ b/content/terraform/v1.13.x/docs/language/meta-arguments.mdx @@ -186,7 +186,7 @@ The `lifecycle` block accepts a rule that customizes how Terraform performs the | Rule | Description | Terraform block | | --- | --- | --- | | `create_before_destroy` | Terraform creates a replacement resource before destroying the current resource. | `resource` | -| `prevent_destroy` | Terraform rejects operations to destroy the resource and returns an error. | `resource` | +| `prevent_destroy` | Terraform rejects operations to destroy the resource and returns an error. This rule doesn't prevent Terraform from destroying a resource if you remove its configuration. Refer to [Remove a resource from state](/terraform/language/state/remove) for instructions on how to remove a resource from state without destroying the actual resource. | `resource` | | `ignore_changes` | Specifies a list of resource attributes that Terraform ignores changes to. Otherwise, Terraform attempts to update the actual resource to match the configuration. | `resource` | | `replace_triggered_by` | Terraform replaces the resource when any of the referenced resources or specified attributes change. | `resource` | | `precondition` | Specifies a condition that Terraform evaluates before creating the resource. | `data`, `ephemeral`, `resource` |