terraform-docs scans Terraform modules and writes documentation for inputs, outputs, providers, and resources. Output formats include Markdown, AsciiDoc, and JSON.
Overview
terraform-docs is a standalone utility that generates reference documentation from Terraform module source. Running it in a module directory can update a README or write to configured files, with behavior driven by a .terraform-docs.yml config file searched in the module root, .config folders, or the user home directory.
Formatters cover Markdown tables, AsciiDoc, JSON, and others, with optional custom content templates that inject generated sections or include other files. Sections can be shown or hidden explicitly, and plugins can register additional formatters when placed in a tfdocs plugins directory and named in configuration.
Distribution includes Homebrew and Scoop on macOS and Windows, Chocolatey, release binaries, go install, and a Docker image that mounts a directory of .tf files. GitHub Actions and pre-commit hooks can regenerate docs on each commit. Parts of the codebase can also be imported as a Go library.
Key features
- Markdown, AsciiDoc, and JSON output
- YAML configuration file support
- Custom content templates
- Docker container execution
- GitHub Action for CI updates
- pre-commit hook integration
- Pluggable custom formatters
- Go library APIs for extensions
Use cases
- Keep Terraform module READMEs current
- Publish module input and output tables
- Automate docs in pull request CI
- Generate AsciiDoc or JSON module specs