Open mbrancato opened 4 years ago
Hi @mbrancato! Thanks for sharing this use-case.
Running terraform console
without an initialized backend would essentially mean making it behave as if the state is empty, because the state comes from the backend. In principle that could allow evaluating expressions that only rely on information from the configuration, but expressions that rely on information that is only stored in the state would return the same error seen today if you run terraform console
before running terraform apply
and try to use something that can't be known until apply is finished.
I personally tend to run terraform console
in an empty directory (no .tf
files at all) when I just want to e.g. try out built-in functions with constant values, or try out for
expressions, etc. I can see that it could potentially be useful to also try expressions deriving from values already present in your configuration while you are investigating possible ways to extend it.
Does that seem like it would be sufficient for the uses you have in mind?
I usually use an empty folder as well, I'm mostly trying to test out functions or expressions as well. Of course, anything more in depth I just create a .tf
file somewhere.
I don't feel like Terraform console is an in-depth debugging tool, just quick testing, etc. The issue I had here was I was debugging some calculated locals that were used and was hard to duplicate. I ended up copying to a new folder and making .tf
files and later deleting.
I personally tend to run terraform console in an empty directory (no .tf files at all) when I just want to e.g. try out built-in functions with constant values,
This is a workaround but this shouldn't be the way to go.
terraform console
by it's purpose looks like a tool that should perfectly work with -backend=false
switch to it - if I want to experiment with expressions not necessarily in my state, I don't need to use state and needing to work on a side location just to overcome the state requirement is not efficient.
Current Terraform Version
Use-cases
There are times when code has a backend config, and the user wants to test this without modification. With
terraform validate
this can be done withterraform init -backend=false
. Even pulling remote module sources work using this method. However,terraform console
does not support this, meaning the code must be edited and the backend config removed.Attempted Solutions
Proposal
References