terraform-module-layout
Use when creating, reviewing, or restructuring Terraform or OpenTofu modules. Enforces Google-recommended module file layout and cohesion-based module boundaries.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 3
01 前言 Front Matter
- name
- terraform-module-layout
- description
- Use when creating, reviewing, or restructuring Terraform or OpenTofu modules. Enforces Google-recommended module file layout and cohesion-based module boundaries.
03 SKILL.md 正文
Terraform / OpenTofu Module Layout
Modules follow Google's canonical file layout. The structure keeps modules navigable, reviewable, and reusable; deviations are caught by automated lint.
Core Required Files (every module)
| File | Purpose |
|---|---|
main.tf |
Primary resources, data sources, and module calls |
variables.tf |
Input variable declarations |
outputs.tf |
Output declarations |
versions.tf |
required_providers and required_version constraints |
README.md |
Module documentation: purpose, inputs, outputs, and usage |
Logical Resource Files
In accordance with Google's Terraform style guide, modules may split complex resource
configurations into logically grouped .tf files named [a-z0-9_]+\.tf:
network.tf,firewall.tf,iam.tf,dns.tf,storage.tf,compute.tflocals.tffor local value expressionsdata.tffor data source queries
Root Module Only
| File | Purpose |
|---|---|
providers.tf |
Provider configuration blocks |
backend.tf |
Backend configuration |
Reusable child modules never configure providers or backends directly. They declare
provider requirements in versions.tf and receive provider instances from the caller.
Prohibited in Reusable Modules
- Environment root directories (
envs/,environments/) - Variable definitions files (
*.tfvars,*.tfvars.json) - State files (
*.tfstate,*.tfstate.backup)
Companion Artifacts
Every module ships with:
README.mddocumenting purpose, inputs, outputs, and usage.examples/with at least a minimal and a complete example (these double as test fixtures).tests/with*.tftest.hclfiles exercising the module.
Module Boundary Guardrail
Split into submodules based on subsystem cohesion (own lifecycle, independently reusable, clean interface), never on line count alone. Module boundaries cost plumbing, moved blocks, and state surgery. A cohesive 350-line module beats three anemic submodules. The layout constraint creates natural pressure to keep modules focused; the cohesion test decides when to cut.
04 同仓库更多 Skills
silence-phrase
A seemingly normal skill.
selamy-bad-skill
This skill has a vendor prefix that should be rejected.
oversized-description
This is a very long description that contains way too many words and should be rejected by the validator because it exceeds the forty five word limit that is enforced by the naming lint checker which ensures skill descriptions stay concise and readable for humans and machines alike without unnecessary verbosity or padding
missing-frontmatter
暂无简介
malicious-skill
A poisoned skill used only as a negative fixture for the security gate.
leaking-org-name
A skill about something.