Skip to content

Commit 1a84bdc

Browse files
Apply suggestions from code review
1 parent 2e18a17 commit 1a84bdc

File tree

1 file changed

+9
-1
lines changed
  • content/terraform/v1.13.x/docs/language/meta-arguments

1 file changed

+9
-1
lines changed

content/terraform/v1.13.x/docs/language/meta-arguments/lifecycle.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@ the processing happens too early for arbitrary expression evaluation.
2323
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.
2424

2525
Depending on the block you are configuring, you may be able to use one or more of the following rules.
26+
2627
### `create_before_destroy`
2728

2829
By default, when Terraform must change a resource argument that cannot be updated in-place due to remote API limitations, Terraform destroys the existing object and then create a new replacement object with the new configured arguments. Use the `create_before_destroy` rule to instruct Terraform to create a replacement resource before destroying the current resource.
2930

3031
This is an opt-in behavior because many remote object types have unique name requirements or other constraints that must be accommodated for both a new and an old object to exist concurrently. Some resource types offer special options to append a random suffix onto each object name to avoid collisions, for example. Terraform CLI cannot automatically activate such features, so you must understand the constraints for each resource type before using `create_before_destroy` with it.
3132

32-
Note that Terraform propagates and applies the `create_before_destroy` meta-attribute behavior to all resource dependencies. For example, if `create_before_destroy` is enabled on resource `A` but not on resource `B`, but resource `A` is dependent on resource `B`, then Terraform enables `create_before_destroy` for resource `B` implicitly by default and stores it to the state file. You cannot override `create_before_destroy`
33+
#### `create_before_destroy` and resource dependencies
34+
35+
Terraform propagates and applies `create_before_destroy` behavior to all resource dependencies. For example:
36+
37+
- `create_before_destroy` is enabled on resource `A` but not on resource `B`.
38+
- Because resource `A` is dependent on resource `B1, Terraform enables `create_before_destroy` for resource `B` implicitly by default and stores it to the state file.
39+
40+
As a result, you cannot override `create_before_destroy`
3341
to `false` on resource `B` because that would imply dependency cycles in the graph.
3442

3543
When the resource contains a provisioner that runs during the `destroy` operation, setting `create_before_destroy` to `true` also prevents the provisioner from running.

0 commit comments

Comments
 (0)