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

Add The possibility to export TF Documentation #178

Closed
xescugc opened this issue Mar 25, 2022 Discussed in #177 · 1 comment · Fixed by #180
Closed

Add The possibility to export TF Documentation #178

xescugc opened this issue Mar 25, 2022 Discussed in #177 · 1 comment · Fixed by #180
Assignees

Comments

@xescugc
Copy link
Member

xescugc commented Mar 25, 2022

Discussed in #177

Originally posted by matthieupetite March 24, 2022
Hello,

I am trying to automaticaly document my terraform code and I use inframap to generate the diagram that is include in my readme.md file of my repo at precomit stage. That's a nice point but it could be a good Idea to have the ability to also generate some other output such as json data related to the object present in the diagram.

That way you will have the ability to build accurate documentation on what is deployed.

sample

Diagram

result

azurerm_virtual_vwan.wan

Attribute Value description
name blablabla
resource_group_name blablabla
@xescugc
Copy link
Member Author

xescugc commented Mar 25, 2022

I'll transfer this to an issue.

I'll add a new option to choose the destination of a generated JSON file which will have the information found on the State/HCL.

Internally on the generate.FromState we already return a config, I'll validate the format to see if it's adequate and expose it to be written into a file. HCL does not have it yet but it should be easy to also make it return as it's kept internally but never returned.

The current format is something like

{
  "resources": {
    "azurerm_virtual_wan": {
      "vwan": {
        "name": "value-name"
      }
    }
  }
}

but I think that for the actual file, as it has to be a representation of the Nodes, we'll go for something along the lines of

{
  "azurerm_virtual_wan.vwan": {
    "name": "value-name"
  }
}

As it's easy/faster to parse and understand, each of the first level keys will be a node on the graph.

The only thing that for now we'll not have is the description as it would be weird to add it to this format, as it would need to be for each attribute, we could check for an improvement and on each attribute have a {"value": "attr-value", "description": "attr-description"} but for now I think I prefer to KISS and return what has been read from the HCL/State.

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

Successfully merging a pull request may close this issue.

1 participant