terraform-docs Terraform module docs
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
terraform-docs markdown table .
terraform-docs markdown table --output-file README.md
.
terraform-docs json .
terraform-docs pretty .
terraform-docs -c .terraform-docs.yml .
terraform-docs --output-check .
terraform-docs --recursive .
terraform-docs version
Concepts
- Module .tf files variables, outputs
- terraform-docs format + sections
- Output stdout or file
- README.md between markers
Install
brew install terraform-docs
go install
github.com/terraform-docs/terraform-docs@<version>
scoop install terraform-docs
choco install terraform-docs
docker run --rm -v "$(pwd):/terraform-docs" -u $(id
-u) quay.io/terraform-docs/terraform-docs:<version>
markdown /terraform-docs
terraform-docs version
Formats
terraform-docs markdown table <path>
terraform-docs markdown document <path>
terraform-docs asciidoc table <path>
terraform-docs asciidoc document <path>
terraform-docs json <path>
terraform-docs yaml <path>
terraform-docs toml <path>
terraform-docs xml <path>
terraform-docs pretty <path>
terraform-docs tfvars hcl <path>
terraform-docs tfvars json <path>
Sections
--show <section>
--hide <section>
--hide providers,footer
--sort-by <name|required|type>
--sort=false--header-from <file>
--footer-from <file>
--read-comments=false
--lockfile=false
Output to file
--output-file <file>
--output-mode inject
--output-mode replace
--output-template <tpl>
--output-check--output-values--output-values-from <file>
Submodules
--recursive--recursive-path <dir>
--recursive-include-main=false
--recursive-exclude <dir>
Config file
-c, --config <file>
formatter: "markdown table"
version: ">= 0.20, < 1.0"
header-from: main.tf
sections: { show: [...], hide: [...] }
output: { file: README.md, mode: inject }
recursive: { enabled: true, path: modules }
sort: { enabled: true, by: name }
settings: { anchor: false, required: false }
content: "{{ .Header }}..."
Ignore blocks
# terraform-docs-ignore
Automation
repo:
https://github.com/terraform-docs/terraform-docs
id: terraform-docs-go
id: terraform-docs-docker
uses: terraform-docs/gh-actions@main
Recipes
<!-- BEGIN_TF_DOCS --><!-- END_TF_DOCS --># the block between them is regenerated
formatter: "markdown table"output: file: README.md mode: injectsort: by: required
repos: - repo: https://github.com/terraform-docs/terraform-docs rev: "v0.24.0" hooks: - id: terraform-docs-go args: ["--output-file", "README.md", "./modules/vpc"]
terraform-docs --output-check -c .terraform-docs.yml .# fails when README.md differs from the generated docs



