You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While making Terraform configuration dynamic, users may sometimes leverage variable in a context where it's not appropriate, such as when the variable will never be provided from the outside (either as module input or by user).
Typically the user would encode the values in default, e.g.
This may most likely be a result of them not knowing about or how to use local values, i.e. not knowing the same goal can be achieved more elegantly with
locals {
internal_name="foobar"
}
We may not always know the context to be able to reliably tell when a local value is more appropriate than a variable, therefore we cannot report this as a diagnostic.
We can however make it easier for the user to turn existing variables with defaults into local values.
Proposal
Provide refactor.rewrite code action which turns any variable with default into a locals entry
The text was updated successfully, but these errors were encountered:
Background
While making Terraform configuration dynamic, users may sometimes leverage variable in a context where it's not appropriate, such as when the variable will never be provided from the outside (either as module input or by user).
Typically the user would encode the values in
default
, e.g.This may most likely be a result of them not knowing about or how to use local values, i.e. not knowing the same goal can be achieved more elegantly with
We may not always know the context to be able to reliably tell when a local value is more appropriate than a variable, therefore we cannot report this as a diagnostic.
We can however make it easier for the user to turn existing variables with defaults into local values.
Proposal
refactor.rewrite
code action which turns anyvariable
withdefault
into alocals
entryThe text was updated successfully, but these errors were encountered: