Skip to main content

tfvars2markdown

Converts Terraform 0.12+ variables file into a Markdown table

Why tfvars2markdown

Friends don't let friends provide Terraform modules without READMEs containing input variables and outputs.

This Python package can generate Markdown-flavored tables for input variables for you by reading .tf files in a folder.

Generated Markdown table is compatible with the following services:

  • Github
  • Bitbucket
  • GitLab

Install

pip install tfvars2markdown

Usage

tfvars2markdown my_vars.tf

Options

Argument Description Default value Required
tf_vars_file Path to the .tf file containing variables - True
-t/--no-ticks Disable backticks around values in "Type" and "Default" columns False False
-d/--heading Changes the default "Inputs" heading. Only first level heading (#) is supported. Inputs False

Examples

Defaults

$ tfvars2markdown vars.tf
# Inputs
|    Name    |                                      Description                                      |      Type      |         Default         | Required |
|------------|---------------------------------------------------------------------------------------|:--------------:|:-----------------------:|:--------:|
| some_var_1 | Some description var_1                                                                |    `string`    |          `foo`          |   yes    |
| some_var_2 | Some description var_2                                                                |     `bool`     |         `False`         |   yes    |
| some_var_3 | Some description var_3                                                                |    `number`    |          `12`           |   yes    |
| some_var_4 | -                                                                                     | `list(string)` | `['foo', 'bar', 'baz']` |   yes    |
| some_var_5 | Some description var_5. This is a very long description with unicode characters ćšđž |  `list(bool)`  |  `[True, True, False]`  |   yes    |
| some_var_6 | Some description var_6                                                                | `list(number)` |       `[1, 2, 3]`       |   yes    |
| some_var_7 | Some description var_7. No defaults provided                                          |     `any`      |            -            |   yes    |
| some_var_8 | Some description var_8. No type or default provided                                   |       -        |            -            |   yes    |
| some_var_9 | Some description var_8. No type or default provided                                   |       -        |            -            |   yes    |

No backticks

$ tfvars2markdown --no-ticks vars.tf
# Inputs
|    Name    |                                      Description                                      |     Type     |        Default        | Required |
|------------|---------------------------------------------------------------------------------------|:------------:|:---------------------:|:--------:|
| some_var_1 | Some description var_1                                                                |    string    |          foo          |   yes    |
| some_var_2 | Some description var_2                                                                |     bool     |         False         |   yes    |

Different heading

$ tfvars2markdown --heading "my input vars" vars.tf
# my input vars
|    Name    |                                      Description                                      |      Type      |         Default         | Required |
|------------|---------------------------------------------------------------------------------------|:--------------:|:-----------------------:|:--------:|
| some_var_1 | Some description var_1                                                                |    `string`    |          `foo`          |   yes    |
| some_var_2 | Some description var_2                                                                |     `bool`     |         `False`         |   yes    |

Due to limitations in pytablewriter only first level heading (#) is supported.

Tests

Install test_requirements.txt and run

python -m unittest discover

Metadata

Release files for tfvars2markdown 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tfvars2markdown 0.0.4
File Size Uploaded
tfvars2markdown-0.0.4.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tfvars2markdown 0.0.4
File Interpreter ABI Platform
tfvars2markdown-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / tfvars2markdown-0.0.4.tar.gz

Download URL tfvars2markdown-0.0.4.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
80beb8a56b8030003ed509b68c917a7465b8a5f0bd9318f83c2a01799007fd98
BLAKE2b-256 checksum
How to use checksums
0dc216efe42519d879e531f1f3bec06c91701faafe45bd159a8dc95e39cb87e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release files / tfvars2markdown-0.0.4-py3-none-any.whl

Download URL tfvars2markdown-0.0.4-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a79dfdf6ddf23f53492f1e8a994ec1650da4c0a2f022a59f334821d2bb51e569
BLAKE2b-256 checksum
How to use checksums
7e369dc38151000cf893cfa3d3e2404bb39201e2776b13d8839d3a1c2ee5162b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page