Terraform Module Documentation Generation Prompt
Auto-generate clear, consistent module documentation with terraform-docs — inputs, outputs, requirements, usage examples — and enforce it in CI so READMEs never drift from the code.
- Target user
- Module authors and platform teams standardizing module docs
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a Terraform module maintainer who treats documentation as a first-class deliverable. Help me produce and enforce high-quality module docs using terraform-docs. I will provide: - The module's variables, outputs, and provider/version requirements - The intended consumers (internal teams, public registry) - Existing README (if any) and our doc conventions - CI system (GitHub Actions, GitLab, pre-commit) Your job: 1. **terraform-docs config** — produce a `.terraform-docs.yml` that renders Markdown tables for Requirements, Providers, Inputs, Outputs, and Resources, sorted by name, with required inputs surfaced clearly. Choose `markdown table` vs `document` format and justify it. 2. **Injection markers** — set up `<!-- BEGIN_TF_DOCS -->` / `<!-- END_TF_DOCS -->` markers in the README so generated content is injected without clobbering hand-written prose. 3. **Hand-written sections** — draft the parts terraform-docs cannot generate: a one-paragraph purpose statement, a copy-pasteable minimal usage example, an advanced example, and a "When NOT to use this module" note. 4. **Variable descriptions** — review my variable `description` fields and rewrite weak ones so each states what it controls, the unit/format, and the effect of the default. Flag any variable missing a description. 5. **Examples directory** — propose an `examples/` layout (e.g. `examples/basic`, `examples/complete`) that doubles as documentation and as test fixtures. 6. **CI enforcement** — provide both a `pre-commit` hook (`terraform-docs` hook) and a CI check that runs `terraform-docs --output-check` and fails the build if the README is stale. 7. **Registry readiness** — confirm the structure matches the Terraform Registry's expectations (README, examples, semantic version tags) if this module will be published. Output as: (a) `.terraform-docs.yml`, (b) a complete README template with markers and hand-written sections, (c) rewritten variable descriptions, (d) the pre-commit + CI config, (e) a short style guide for future modules. Bias toward: docs generated from code, zero manual table maintenance, examples that are also tested.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Terraform for_each Set vs Map Keys Prompt
Decide whether a `for_each` should iterate a set of strings or a map of objects so instance keys stay stable, readable, and free of churn when the collection changes.
-
Terraform Aliased Provider Passing to Nested Modules Prompt
Wire aliased providers (multi-region, multi-account) down through nested module trees using explicit `configuration_aliases` and `providers = {}` maps instead of implicit inheritance.
-
Terraform Multi-Region Fan-Out Design Prompt
Design a maintainable pattern for deploying the same stack across many regions using provider aliases and module fan-out — avoiding the dead-end where provider configurations cannot be created from `for_each` and copy-pasted per-region blocks proliferate.
-
Terraform Conditional Resource Pattern Review Prompt
Review and fix conditional resource creation (count toggles, ternaries, optional features) for safety and idempotency.
More Terraform prompts & error guides
Browse every Terraform prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.