-
Notifications
You must be signed in to change notification settings - Fork 187
Description
Extension Version
v2.34.5
Problem Statement
In big projects with many (nested) modules and variables from different environments, it can be tedious to keep track of what the actual values of the variables inside a module (or even a normal Terraform file on the root level) are. The task of looking up where a module is used, repetitively tracing the variable back until reaching the top-level where the .tfvars
file is defined, just for one single variable value (or maybe the group of variables from the nested module) can be challenging, especially in bigger projects.
The same tedious "look up" task also exists when tracing back outputs used in other modules to the module of origin.
Expected User Experience
It should not be as tedious to work with Terraform as it currently is in larger projects. You should quickly be able to get the actual values from variables (or maybe outputs as well) to save precious time.
Note
The complexity only exists because of the combination of two fundamental, important features: variables & modules
Proposal
This Terraform plugin could provide an opt-in feature to display inlay hints with the resolved values of the variable (only locale variables, no remote variables for the first implementation) or of the output (if it is known before applying, e.g., the output references the name of a resource that is hard coded into the module resource).
Difficulties
Difficulties of such an additional features are:
- Variants: Multiple values for one variables (because modules can be used multiple times).
- (Efficient) Recursive resolution: The whole project needs to be scanned because every module can be used from anywhere if the path matches.
- Caching + Cache Invalidation
- Intuitive Visualisation of complex objects (variables are not limited to naiv types like
string
,number
, ... but can be nested objects themselves making it difficult to display them in just an inlay hint)
Commands and Settings
The exact behaviour and additional commands of such an additional feature could be further discussed. Nonetheless, here are some ideas for you to get the ball rolling:
- New commands:
- Delete cache
- Toggle inlay hints (basically turn this feature on/off)
- Various commands to change any of the following settings
- New settings / options:
- Active / Not active (basic setting for turning this feature on/off)
- How to display complex objects (only show first value / hover for details / ...)
- How to display variants (only show first variant / hover for all variants / ...)
References
To better demonstrate my proposal, I quickly and dirtily vibe-coded my own Terraform Variables Resolution VS Code Extension which displays the resolved variables like this:

Note
I'm not an expert in writing VS Code extensions in general (that's the reason why it's vibe-coded), so I advice not to use the existing code of my plugin for implementations in the official Hashicorp Terraform plugin 😉
Help Wanted
- I'm interested in contributing a fix myself
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment (this is a rather big feature proposal, so we might not want to tackle it on your own)