Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mdb/terraputs

A CLI to generate Terraform outputs documentation
https://github.com/mdb/terraputs

terraform

Last synced: 3 months ago
JSON representation

A CLI to generate Terraform outputs documentation

Awesome Lists containing this project

README

        

[![CI/CD](https://github.com/mdb/terraputs/actions/workflows/main.yml/badge.svg)](https://github.com/mdb/terraputs/actions/workflows/main.yml)

# terraputs

A CLI to generate Terraform outputs documentation.

## What's the use case?

`terraputs` analyzes the contents of a [terraform state](https://www.terraform.io/docs/language/state/index.html)
file and generates Markdown or HTML documentation from its [outputs](https://www.terraform.io/docs/language/values/outputs.html).

A common workflow might execute `terraputs -state $(terraform show -json) > outputs.md` after each
invocation of `terraform apply`, then commit `outputs.md` to source control or publish its contents to
offer up-to-date documentation about resources managed by a Terraform project.

## Usage

```
terraputs -h
Usage of terraputs:
-description string
Optional; a contextual description preceding the outputs. (default "Terraform state outputs.")
-heading string
Optional; the heading text for use in the printed output. (default "Outputs")
-output string
Optional; the output format. Supported values: md, html. (default "md")
-state string
Optional; the state JSON output by 'terraform show -json'. Read from stdin if omitted
-state-file string
Optional; the path to a local file containing 'terraform show -json' output
```

A few typical usage examples:

```
# terraputs can accept arbitrary state as a string argument on the command line:
terraputs -state "$(terraform show -json)" -heading "Terraform Outputs"

# or directly from standard input, if the -state option is omitted. to read
# directly from terraform, consider:
terraform show -json | terraputs -heading "Terraform Outputs"

# or read a tfstate JSON file from the filesystem:
terraform show -json > show.json
terraputs < show.json
```

### Results examples

Example markdown output

```
# Terraform Outputs

Terraform state outputs.

| Output | Value | Type
| --- | --- | --- |
| a_basic_map | map[foo:bar number:42] | map[string]interface {}
| a_list | [foo bar] | []interface {}
| a_nested_map | map[baz:map[bar:baz id:123] foo:bar number:42] | map[string]interface {}
| a_sensitive_value | sensitive; redacted | string
| a_string | foo | string
```

Markdown output rendered via GitHub-flavored markdown

# Terraform Outputs

Terraform state outputs.

| Output | Value | Type
| --- | --- | --- |
| a_basic_map | map[foo:bar number:42] | map[string]interface {}
| a_list | [foo bar] | []interface {}
| a_nested_map | map[baz:map[bar:baz id:123] foo:bar number:42] | map[string]interface {}
| a_sensitive_value | sensitive; redacted | string
| a_string | foo | string

Example HTML output

```html

Outputs


Terraform state outputs.


Output
Value
Type


a_basic_map

{

"foo": "bar",
"number": 42
}

map[string]interface {}


a_list

[

"foo",
"bar"
]

[]interface {}


a_nested_map

{

"baz": {
"bar": "baz",
"id": "123"
},
"foo": "bar",
"number": 42
}

map[string]interface {}


a_sensitive_value

sensitive; redacted

string


a_string

"foo"

string

```

HTML output rendered via GitHub-flavored markdown

Outputs


Terraform state outputs.


Output
Value
Type


a_basic_map

{

"foo": "bar",
"number": 42
}

map[string]interface {}


a_list

[

"foo",
"bar"
]

[]interface {}


a_nested_map

{

"baz": {
"bar": "baz",
"id": "123"
},
"foo": "bar",
"number": 42
}

map[string]interface {}


a_sensitive_value

sensitive; redacted

string


a_string

"foo"

string