Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support terraform console with -backend=false #24094

Open
mbrancato opened this issue Feb 13, 2020 · 3 comments
Open

Support terraform console with -backend=false #24094

mbrancato opened this issue Feb 13, 2020 · 3 comments

Comments

@mbrancato
Copy link

Current Terraform Version

Terraform v0.12.20

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 with terraform 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

@apparentlymart
Copy link
Member

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?

@mbrancato
Copy link
Author

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.

@tymik
Copy link

tymik commented Nov 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants