You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/terraform/v1.12.x/docs/language/block/resource.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -315,7 +315,7 @@ resource {
315
315
You can specify the following lifecycle rules to manage how Terraform performs operations on the resource:
316
316
317
317
-[`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource.
318
-
-[`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error.
318
+
-[`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).
319
319
-[`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.
320
320
-[`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change.
321
321
-[`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 {
369
369
370
370
Use this argument to prevent team members from accidentally replacing critical infrastructure, such as database instances.
371
371
372
-
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.
372
+
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.
373
+
374
+
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).
Copy file name to clipboardExpand all lines: content/terraform/v1.12.x/docs/language/meta-arguments.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,7 +180,7 @@ The `lifecycle` block accepts a rule that customizes how Terraform performs the
180
180
| Rule | Description | Terraform block |
181
181
| --- | --- | --- |
182
182
|`create_before_destroy`| Terraform creates a replacement resource before destroying the current resource. |`resource`|
183
-
|`prevent_destroy`| Terraform rejects operations to destroy the resource and returns an error. |`resource`|
183
+
|`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`|
184
184
|`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`|
185
185
|`replace_triggered_by`| Terraform replaces the resource when any of the referenced resources or specified attributes change. |`resource`|
186
186
|`precondition`| Specifies a condition that Terraform evaluates before creating the resource. |`data`, `ephemeral`, `resource`|
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/block/resource.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -321,7 +321,7 @@ resource {
321
321
You can specify the following lifecycle rules to manage how Terraform performs operations on the resource:
322
322
323
323
-[`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource.
324
-
-[`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error.
324
+
-[`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).
325
325
-[`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.
326
326
-[`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change.
327
327
-[`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 {
375
375
376
376
Use this argument to prevent team members from accidentally replacing critical infrastructure, such as database instances.
377
377
378
-
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.
378
+
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.
379
+
380
+
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).
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/meta-arguments.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,7 +186,7 @@ The `lifecycle` block accepts a rule that customizes how Terraform performs the
186
186
| Rule | Description | Terraform block |
187
187
| --- | --- | --- |
188
188
|`create_before_destroy`| Terraform creates a replacement resource before destroying the current resource. |`resource`|
189
-
|`prevent_destroy`| Terraform rejects operations to destroy the resource and returns an error. |`resource`|
189
+
|`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`|
190
190
|`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`|
191
191
|`replace_triggered_by`| Terraform replaces the resource when any of the referenced resources or specified attributes change. |`resource`|
192
192
|`precondition`| Specifies a condition that Terraform evaluates before creating the resource. |`data`, `ephemeral`, `resource`|
Copy file name to clipboardExpand all lines: content/terraform/v1.14.x (beta)/docs/language/block/resource.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,7 +330,7 @@ You can specify the following lifecycle rules to manage how Terraform performs o
330
330
331
331
-[`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.
332
332
-[`create_before_destroy`](#create_before_destroy): Terraform creates a replacement resource before destroying the current resource.
333
-
-[`prevent_destroy`](#prevent_destroy): Terraform rejects operations to destroy the resource and returns an error.
333
+
-[`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).
334
334
-[`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.
335
335
-[`replace_triggered_by`](#replace-triggered_by): Terraform replaces the resource when any of the referenced resources or specified attributes change.
336
336
-[`precondition`](#precondition): Specifies a condition that Terraform evaluates before creating the resource. Refer to [Validate your configuration](/terraform/language/validate) for more information.
Copy file name to clipboardExpand all lines: content/terraform/v1.14.x (beta)/docs/language/meta-arguments.mdx
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,17 +185,26 @@ Terraform performs the following operations when you apply a configuration:
185
185
1. Creates resources defined in the configuration that are not associated with a real infrastructure object in the state.
186
186
1. Destroys resources that exist in the state but not in the configuration.
187
187
1. Updates in-place resources whose arguments have changed.
188
-
1. Destroys and re-create resources whose arguments have changed but that Terraform cannot update in-place because of remote API limitations.
188
+
1. Destroys and re-creates resources whose arguments have changed but that Terraform cannot update in-place because of remote API limitations.
189
189
1. Invokes actions that are configured to run during an apply operation.
190
190
191
-
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:
191
+
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.
192
192
193
+
### State
194
+
195
+
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.
196
+
197
+
Terraform records the results of `precondition` and `postcondition` checks to state, but not the contents of the checks.
198
+
199
+
### Rules
200
+
201
+
The following table describes support for each `lifecycle` rule:
193
202
194
203
| Rule | Description | Terraform block |
195
204
| --- | --- | --- |
196
205
|`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`|
197
206
|`create_before_destroy`| Terraform creates a replacement resource before destroying the current resource. |`resource`|
198
-
|`prevent_destroy`| Terraform rejects operations to destroy the resource and returns an error. |`resource`|
207
+
|`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`|
199
208
|`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`|
200
209
|`replace_triggered_by`| Terraform replaces the resource when any of the referenced resources or specified attributes change. |`resource`|
201
210
|`precondition`| Specifies a condition that Terraform evaluates before creating the resource. |`data`, `ephemeral`, `resource`|
0 commit comments