mingrammer / diagrams

:art: Diagram as Code for prototyping cloud system architectures
https://diagrams.mingrammer.com
MIT License
35.65k stars 2.32k forks source link

Feature request: Terraform support #6

Open mectors opened 4 years ago

mectors commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Thank you for giving an example.

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

ghost commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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

guidiego commented 3 years ago

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

dhirschfeld commented 3 years ago

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

sfertman commented 3 years ago

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

tbugfinder commented 3 years ago

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

cybrarymin commented 2 years ago

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 commented 1 year ago

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

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

vinsten99 commented 1 year ago

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 commented 7 months ago

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 commented 4 months ago

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