Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions content/terraform/v1.12.x/docs/language/block/resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
6 changes: 4 additions & 2 deletions content/terraform/v1.13.x/docs/language/block/resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

### 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` |
Expand Down
Loading