vscode-terraform
vscode-terraform copied to clipboard
Rename a symbol within a module
Use Cases
While working on a module of non-trivial size with many references users would benefit from having the ability to rename identifiers.
Specifically:
- local value names
- variable names
- module (call) names
- provider aliases
- resource reference names
- data sources reference names
Out of scope
Cross-module
Users would also indeed benefit from performing such renames across modules which reference each other - which specifically affects variable and outputs names, but we can ship renaming capability within a single module first - which can be still useful.
We can rely on terraform's strict validation mechanism which wouldn't allow the user to plan or apply a config where input is missing, or reference is referring to wrong name.
TODO: Create a separate issue
tfvars
TODO: Create a separate issue
Expected User Experience

User can click Rename from the context menu in positions described below.
Local Values

Variables

Resources / Data Sources

Provider Aliases

Module (Call) Reference Names

Proposal
TODO
Outstanding questions
- Should/could we also (optionally) rename the name within state via
terraform state mv?
With the addition of the refactoring features in v1.1, I think it's worth considering whether renaming a resource should automatically generated a moved block adjacent to it, which would therefore record that the rename took place in a way that the next terraform apply can take into account automatically.
I would not generally suggest having the editor integrations implicitly run any actions that will create new state snapshots, because I think that blurs the line between developing a change and applying that change. It could perhaps be okay to allow a user to explicitly run a command like terraform state mv, but it could be pretty disruptive for it to happen automatically without any explicit direction in case someone else runs terraform apply on the unmodified configuration before the author's changes have been merged. (Terraform would propose to delete the object at the new address, because it doesn't appear to exist in the configuration from the perspective of the other collaborator.)
How is this not a feature!?
Is this being worked on or at least on the roadmap? It's something that is present in other IDE like Jetbrain's PHPStorm, so I am quite surprised it is still not supported on this VS Code extension.
+1 for this obviously
Generating moved blocks from this would be an incredible feature for productivity! Refactoring in Terraform is a quite tedious effort, even with tools like tfautomv.
Any progress on this issue?