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

Feature request: Terraform support #6

Open
mectors opened this issue Feb 11, 2020 · 16 comments
Open

Feature request: Terraform support #6

mectors opened this issue Feb 11, 2020 · 16 comments
Labels
kind/feature New feature or request proposal Suggestion proposed status/need-to-review Need to review

Comments

@mectors
Copy link

mectors commented Feb 11, 2020

The diagrams that are generated are amazingly good looking. Excellent job! If a terraform script could be used as input to automatically generate them then any cloud consultant and audit department would use it in their DevOps pipeline because just like JavaDocs for Java, it would be the no brainier to generate cloud documentation. Would that be possible?

@mingrammer
Copy link
Owner

mingrammer commented Feb 11, 2020

What a great idea!

It might be possible with Resource Graph concept. Fortunately, terraform support terraform graph command (which generates Graphviz code), so we could read the terraform script like this way:

$ terraform graph | diagrams --terraform -o graph.png

So I need to create diagrams command line to support it.

Read the Graphviz code generated from terraform graph is much easier than read the HCL scripts directly.

@j-martin
Copy link

j-martin commented Feb 12, 2020

That's a great idea. Using terraform graph is a good starting point, but I think some kind of mapping code would be required to denote relations that go beyond what can be represented with Terraform alone.

E.g. A few instances/instance groups are in a VPC, to denote that they communicate to each, you would need to explicitly tell diagram to draw a line between them. I don't think it can safely be inferred from Terraform. E.g: the only indication may be from a certain firewall rule like allow all instances in the VPC to communicate with port 443.

To reiterate, this is a great idea and we would definitely use that.

@mingrammer
Copy link
Owner

Thank you for giving an example.

I'll have to test some complicated Terraform codes to see if this is possible.

@ghost
Copy link

ghost commented May 19, 2020

Upvote for that request. I agree that it will be hard, if not impossible to get all relations (eg. between instances), from terraform natively. Maybe adding additional "meta" information, like tags or so, might help. Aside from the graph functionality, the statefile might be a source for gathering information.

@meshuga
Copy link
Contributor

meshuga commented Jun 9, 2020

It might be useful to take a look at a tool I help developing - https://github.com/Cloud-Architects/cloud-discovery.

We use this library as a visualization engine, provide different commands to report different parts of the infrastructure and have on-top aggregations to simplify usually complex solutions.

@xescugc
Copy link

xescugc commented Jul 16, 2020

Hi all!

At Cycloid we have just have released a tool that does exactly what's been asked here, generate a Graph from HCL/State in a more human readable way than terraform graph, the tool is InfraMap https://github.com/cycloidio/inframap.

The format in which the graphs are printed can be customized, for now we only support DOT, but would be possible to change it and add a diagrams printer format.

Thanks you all!.

@rightaway
Copy link

The idea to provide meta information to the graphs from terraform code would be very useful too.

@guidiego
Copy link

I think the reverse! If I create a Graph could I create automatically a terraform code to deploy my environment?

@dhirschfeld
Copy link

There might be some useful prior-art over in in https://github.com/28mm/blast-radius

@sfertman
Copy link

Another option is to parse tfstate which is a "simple" json instead of HCL which is much more complex.

@tbugfinder
Copy link

HCL2 -> JSON: https://pypi.org/project/python-hcl2/

@cybrarymin
Copy link

cybrarymin commented Jun 21, 2022

What a great idea!

It might be possible with Resource Graph concept. Fortunately, terraform support terraform graph command (which generates Graphviz code), so we could read the terraform script like this way:

$ terraform graph | diagrams --terraform -o graph.png

So I need to create diagrams command line to support it.

Read the Graphviz code generated from terraform graph is much easier than read the HCL scripts directly.

Hello mingrammer ,I hope you are doing well. I just wanted to ask, did you have any progress for the requested feature?? It is a precious tool but it needs lots of manual coding. In case of major changes in your infra it takes weeks to find details about communications and coding them.

@jeremy-donson
Copy link

jeremy-donson commented Dec 2, 2022

Two requests that are complementary, yet necessarily in order below:

  • Reverse engineering of diagrams from tf plan code.

    • With diagrams, docs and /etc/hosts and ansible inventory could be generated?
  • Forward engineering of diagrams to tf plan code.

    • Sounds great, but this DEPENDS upon graphical and lexical standards.

Are either of these on the roadmap in any organized way?

@vinsten99
Copy link

vinsten99 commented May 12, 2023

Any update on this? or any work around for now on how we can automatically or dynamically generate diagrams for our terraform code? 🙏🏻. @mingrammer

@alexlegland
Copy link

The diagrams that are generated are amazingly good looking. Excellent job! If a terraform script could be used as input to automatically generate them then any cloud consultant and audit department would use it in their DevOps pipeline because just like JavaDocs for Java, it would be the no brainier to generate cloud documentation. Would that be possible?

Hi guys,

Mingrammer is really a cool tool but of course there are just things that requires extra work to make it functional. So is generating Terraform diagrams from code. We really spent lots of time and work to make it available.
With Holori you can now generate terraform diagrams in GitHub Pull request. We support AWS, Azure and GCP and offer 50/run per month for free! Give it a spin : https://app.holori.com/

terraform diagram cicd

@icodeforyou-dot-net
Copy link

I think this has been stale for a while now. And abused for advertisements even. Any progress on the actual issue? Anyone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request proposal Suggestion proposed status/need-to-review Need to review
Projects
None yet
Development

No branches or pull requests