mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-23 15:40:07 -06:00
Adding removed
block docs (#1332)
Signed-off-by: Ronny Orot <ronny.orot@gmail.com> Co-authored-by: Janos <86970079+janosdebugs@users.noreply.github.com>
This commit is contained in:
parent
fa638907f1
commit
99b43c98fc
@ -5,6 +5,7 @@ UPGRADE NOTES:
|
||||
|
||||
|
||||
NEW FEATURES:
|
||||
* Add support for a `removed` block that allows users to remove resources or modules from the state without destroying them. ([#1158](https://github.com/opentofu/opentofu/pull/1158))
|
||||
|
||||
ENHANCEMENTS:
|
||||
* Added `templatestring` function that takes a string and renders it as a template using a supplied set of template variables. ([#1223](https://github.com/opentofu/opentofu/pull/1223))
|
||||
@ -20,7 +21,7 @@ ENHANCEMENTS:
|
||||
* Allow test run blocks to reference previous run block's module outputs ([#1129](https://github.com/opentofu/opentofu/pull/1129))
|
||||
* Support the XDG Base Directory Specification ([#1200](https://github.com/opentofu/opentofu/pull/1200))
|
||||
* Allow referencing the output from a test run in the local variables block of another run (tofu test). ([#1254](https://github.com/opentofu/opentofu/pull/1254))
|
||||
* Add support for a `removed` block that allows users to remove resources or modules from the state without destroying them. ([#1158](https://github.com/opentofu/opentofu/pull/1158))
|
||||
* Add documentation for the `removed` block. ([#1332](https://github.com/opentofu/opentofu/pull/1332))
|
||||
|
||||
BUG FIXES:
|
||||
* Fix view hooks unit test flakiness by deterministically waiting for heartbeats to execute ([$1153](https://github.com/opentofu/opentofu/issues/1153))
|
||||
|
@ -29,6 +29,7 @@ In summary, applying an OpenTofu configuration will:
|
||||
|
||||
- _Create_ resources that exist in the configuration but are not associated with a real infrastructure object in the state.
|
||||
- _Destroy_ resources that exist in the state but no longer exist in the configuration.
|
||||
- _Forget_ resources that exist in the state but no longer in the configuration and are referenced in a `removed` block within the configuration.
|
||||
- _Update in-place_ resources whose arguments have changed.
|
||||
- _Destroy and re-create_ resources whose arguments have changed but which cannot be updated in-place due to remote API limitations.
|
||||
|
||||
|
@ -117,6 +117,41 @@ For more information about how OpenTofu manages resources when applying a
|
||||
configuration, see
|
||||
[Resource Behavior](/docs/language/resources/behavior).
|
||||
|
||||
## Removing Resources
|
||||
|
||||
If you remove a resource block from your configuration, OpenTofu will destroy it as a default behavior.
|
||||
|
||||
However, there are instances when you want to remove a resource from your configuration without destroying the
|
||||
corresponding infrastructure object. In such cases, you can remove it from the [OpenTofu state](/docs/language/state)
|
||||
while allowing it to persist in the remote system.
|
||||
|
||||
To achieve this, follow these steps:
|
||||
1. Delete the resource from your configuration.
|
||||
2. Add a removed block instead, specifying the resource address you want to "forget" in the `from` attribute.
|
||||
|
||||
For example:
|
||||
```hcl
|
||||
removed {
|
||||
from = aws_instance.web
|
||||
}
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
The address in the `from` attribute cannot include instance keys (for example, "aws_instance.web[0]").
|
||||
|
||||
:::
|
||||
|
||||
Upon executing `tofu plan`, OpenTofu will indicate that the resource is slated for removal from the state but will not
|
||||
be destroyed.
|
||||
|
||||
The `removed` block can be used to remove specific resources or modules containing multiple resources. For example:
|
||||
```hcl
|
||||
removed {
|
||||
from = module.some_module
|
||||
}
|
||||
```
|
||||
|
||||
## Meta-Arguments
|
||||
|
||||
The OpenTofu language defines several meta-arguments, which can be used with
|
||||
|
Loading…
Reference in New Issue
Block a user