mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 12:58:35 +07:00
There are two modes for saving into file:
- inject: partially replace the target file with generated output
- replace: completely replace the target file with generated output
The output generated by formatters (markdown, asciidoc, etc) will be
inserted into a template before getting saved into the file. This
template can be customized with '--output-template' CLI flag or
corresponding item in '.terraform-docs.yml' config file. Its default
value is:
```
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
```
This consists of three items, all of them are mandatory:
- begin comment
- content variable
- end comment
You may change the wording of comment as you wish, but the comment must
be present in the template.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
3.1 KiB
3.1 KiB
title, description, menu, weight, toc
| title | description | menu | weight | toc | ||||
|---|---|---|---|---|---|---|---|---|
| tfvars json | Generate JSON format of terraform.tfvars of inputs. |
|
961 | true |
Synopsis
Generate JSON format of terraform.tfvars of inputs.
terraform-docs tfvars json [PATH] [flags]
Options
-h, --help help for json
Inherited Options
-c, --config string config file name (default ".terraform-docs.yml")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by-required sort items by name and print required ones first (default false)
--sort-by-type sort items by type of them (default false)
Example
Given the examples module:
terraform-docs tfvars json ./examples/
generates the following output:
{
"bool-1": true,
"bool-2": false,
"bool-3": true,
"bool_default_false": false,
"input-with-code-block": [
"name rack:location"
],
"input-with-pipe": "v1",
"input_with_underscores": null,
"list-1": [
"a",
"b",
"c"
],
"list-2": null,
"list-3": [],
"list_default_empty": [],
"long_type": {
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
},
"map-1": {
"a": 1,
"b": 2,
"c": 3
},
"map-2": null,
"map-3": {},
"no-escape-default-value": "VALUE_WITH_UNDERSCORE",
"number-1": 42,
"number-2": null,
"number-3": "19",
"number-4": 15.75,
"number_default_zero": 0,
"object_default_empty": {},
"string-1": "bar",
"string-2": null,
"string-3": "",
"string-special-chars": "\\.<>[]{}_-",
"string_default_empty": "",
"string_default_null": null,
"string_no_default": null,
"unquoted": null,
"with-url": ""
}