A tool for managing local copies of Terraform provider documentation. This tool helps you maintain local copies of Terraform provider documentation for offline access and browsing.
Shout out to and inspiration from @pbnj for creating terradoc which is where I got the idea for this project originally.
- Clone and maintain local copies of Terraform provider documentation
- Sparse checkout to only download the documentation files
- Support for multiple providers
- Easy updates to keep documentation current
- Generate an index file for easy navigation
- View documentation using
glow
or any markdown viewer
This tool expects providers to have a standard repository structure with a top-level docs
or website/docs
directory.
brew install jreslock/tap/terraform-provider-docs-local
Download the latest release for your platform from the releases page and put the binary in /usr/local/bin
or somewhere on your $PATH, make sure it is exectutable (chmod +x
).
git clone https://github.com/jreslock/terraform-provider-docs-local.git
cd terraform-provider-docs-local
go build
Create a providers.yaml
file with your desired providers. You can name the file anything you would like but the utility looks for a providers.yaml
by default if you prefer less typing. You can optionally specify the desired branch to clone. The default behavior if no branch is specified will auto-detect the HEAD branch from the remote repository.
target_dir: terraform-providers # Optional, defaults to "./terraform-providers"
providers:
aws:
repo: hashicorp/terraform-provider-aws
description: AWS provider for Terraform
branch: main # Optional, if not set we auto-detect the HEAD branch from the remote
azurerm:
repo: hashicorp/terraform-provider-azurerm
description: Azure provider for Terraform
# Clone all providers
terraform-provider-docs-local clone-all
# Clone a specific provider
terraform-provider-docs-local clone-one -p aws
# Clone a specific provider at a desired branch
terraform-provider-docs-local clone-one -p sumologic -b master
# List available providers
terraform-provider-docs-local list
# Update all providers
terraform-provider-docs-local update-all
# Update a specific provider
terraform-provider-docs-local update-one -p aws
# Generate index file
terraform-provider-docs-local index
# Clean up all cloned providers
terraform-provider-docs-local clean
After cloning the providers, you can view the documentation using glow
from within the directory you specified in your providers.yaml
(or whatever you set target_dir
to be):
# Install glow if you haven't already
brew install glow
# View the index
glow .
# Or navigate directly to a provider's documentation
glow terraform-providers/aws/docs/index.md
You can either install the prerequisites locally or use the provided devcontainer:
- Go 1.21 or later
- Task (for running development tasks)
- svu (for version management)
- goreleaser (for releases)
- golangci-lint (for linting)
- pre-commit (for git hooks)
- testify (for testing)
- Install Docker
- Install VS Code
- Install the Remote - Containers extension
- Clone this repository
- Open the repository in VS Code
- When prompted, click "Reopen in Container"
The devcontainer includes all required tools and is pre-configured with:
- Go
- Task
- svu
- goreleaser
- golangci-lint
- pre-commit
- glow
- testify
- VS Code extensions for Go development
- Automatic formatting and linting on save
# Build the binary
task build
# Run tests
task test
# Run linters
task lint
Set up the development environment (this will install hooks and run initial checks):
```bash
task pre-commit-install
```
Additional pre-commit tasks:
# Run pre-commit hooks on all files
task pre-commit-run
# Update pre-commit hooks to latest versions
task pre-commit-update
The pre-commit hooks will run the following checks:
- Code formatting (go-fmt)
- Code vetting (go-vet)
- Import formatting (go-imports)
- Linting (golangci-lint)
- Unit tests (go-unit-tests)
- Build verification (go-build)
- Module tidy check (go-mod-tidy)
- General file checks (trailing whitespace, YAML validity, etc.)
- Create an issue
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request and note the issue in the PR title or description
This project is licensed under the MIT License - see the LICENSE file for details.