Rename Resource
Procedure
- Rename block.
- Rename all references within the module.
- Move state from old name to new.
- Verify empty plan.
Automation
See tfrefactor.
tfrefactor rename my_resource.old my_resource.new
Source code
Before
After
State operations
If not using moved blocks introduced in Terraform 1.1, a state mv
operation must be used to avoid destroying and recreating the resource.
Or, with tfmigrate:
See also.
- Rename resource array.
- Move resource into module.
- Move resource out of module.
- Rename variable.
- Rename local.
- Rename data.