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

graph needs option to disable backend (-backend=false) #32462

Open
nicain opened this issue Jan 5, 2023 · 3 comments
Open

graph needs option to disable backend (-backend=false) #32462

nicain opened this issue Jan 5, 2023 · 3 comments
Labels
enhancement new new issue not yet triaged

Comments

@nicain
Copy link

nicain commented Jan 5, 2023

Terraform Version

Terraform v1.2.8
on linux_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/google v4.37.0
+ provider registry.terraform.io/hashicorp/google-beta v4.45.0
+ provider registry.terraform.io/hashicorp/time v0.9.1

Use Cases

Using terraform graph to build a dot file, when main.tf has a backend configured

Attempted Solutions

Commenting out the backend block in the terraform block accomplished what I need, but I cannot automate it and its a bit cumbersome

Proposal

Include a command line arg similar to -backend=false in from init, to ignore the backend directive. Otherwise I have to comment out the backend directive in the source code to run graph

References

None

@nicain nicain added enhancement new new issue not yet triaged labels Jan 5, 2023
@crw
Copy link
Contributor

crw commented Jan 6, 2023

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@apparentlymart
Copy link
Contributor

Hi @nicain! Thanks for this feature request.

I'd like to hear a little more about what you intend to do with this graph, so we can think about what exactly it would mean to generate a graph without an initialized backend.

The terraform graph command today is effectively showing the internal execution graph which Terraform will use to plan or apply (depending on the graph type you request) the configuration against the most recent state snapshot. That operation inherently requires the state because the state is in important part of creating a plan. For example, the state might cause Terraform to add an additional graph node to destroy an object that currently exists but is not declared in the configuration. Terraform cannot access the state without access to the backend.

I assume you have a different goal that's a little outside of the current intent for terraform graph. Since terraform graph today is just showing the same graph Terraform would use for real execution I expect there will be more to meeting this request than just changing the behavior of the graph command, and so I'd like to hear more about what your goal is so that we can think about some different ways we could change Terraform to give you the information you need.

Thanks!

@sanimalp
Copy link

My use case would be to chase down cycles to eliminate them before committing my changes to the automation system that deploys, and for which I do not have access to attach to the real backend to manipulate directly. For instance, I would run:

terraform init --backend=false
terraform validate
<CYCLE error message produced here!>
terraform graph -draw-cycles --backend=false
<graph analysis output here>

This would allow me to locally debug without the commit-to-automation system step for remote real validation. Not even sure I could run the graph directive in that environment without some sort of admin resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants