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.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. Terraform may also record values in `lifecycle` rules as resource dependencies.
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