| name | building-terraform-modules |
| description | Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(cmd:*) |
| version | 1.23.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["devops","terraform","terraform-modules"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Building Terraform Modules
Overview
Build reusable, production-ready Terraform modules with proper variable definitions, outputs, validation rules, documentation, and examples. Generate modules following HashiCorp's standard module structure for AWS, GCP, and Azure resources with security best practices, tagging conventions, and lifecycle management.
Prerequisites
- Terraform 1.0+ installed (
terraform version)
- Cloud provider credentials configured for the target platform
- Understanding of the infrastructure resources the module will manage
- Familiarity with HCL syntax and Terraform module conventions
terraform-docs installed for automated documentation generation (optional)
Instructions
- Define the module scope: determine which cloud resources the module manages and its input/output contract
- Create the standard module file structure:
main.tf, variables.tf, outputs.tf, versions.tf, locals.tf
- Write
versions.tf with required_version and required_providers blocks pinned to stable versions
- Define input variables in
variables.tf with descriptions, types, defaults, and validation rules
- Implement resources in
main.tf using variables for all configurable values; use locals for computed values
- Add meaningful outputs in
outputs.tf for resource IDs, ARNs, endpoints, and connection strings
- Implement security defaults: encryption enabled, public access blocked, least-privilege IAM, logging enabled
- Create an
examples/ directory with at least one complete usage example showing module invocation
- Generate documentation with
terraform-docs markdown table . > README.md
- Validate the module with
terraform init && terraform validate and test with terraform plan using the example
Output
- Module files:
main.tf, variables.tf, outputs.tf, versions.tf, locals.tf
- Example usage in
examples/basic/main.tf with realistic variable values
- Auto-generated with inputs, outputs, and usage documentation