Guides creation of reusable Terraform modules for AWS, Azure, GCP and OCI infrastructure.
- What it does
- This skill provides patterns and conventions for building reusable Terraform modules covering common cloud infrastructure such as VPCs, Kubernetes clusters, databases and storage across AWS, Azure, GCP and OCI. It describes a standard module layout (main.tf, variables.tf, outputs.tf, versions.tf, examples and tests), shows a worked AWS VPC example with variables, outputs and validation, and lists best practices including semantic versioning, provider pinning, tagging and Terratest testing. It also covers module composition, where one module's outputs feed another's inputs. Two reference files cover AWS and OCI module details.
- When to use it
- Use it when creating reusable infrastructure modules, standardizing cloud resource provisioning across providers, or establishing organizational Terraform standards. It also fits teams implementing infrastructure-as-code best practices or building multi-cloud compatible components.
- Requirements
- Terraform and its HCL configuration language, plus cloud provider credentials for whichever of AWS, Azure, GCP or OCI is targeted. Testing examples rely on Go, Terratest and testify. The skill ships no scripts; it is instructions and reference documents only.
Terraform Module Library
Production-ready Terraform module patterns for AWS, Azure, GCP, and OCI infrastructure.
Purpose
Create reusable, well-tested Terraform modules for common cloud infrastructure patterns across multiple cloud providers.
When to Use
- Build reusable infrastructure components
- Standardize cloud resource provisioning
- Implement infrastructure as code best practices
- Create multi-cloud compatible modules
- Establish organizational Terraform standards
Module Structure
Standard Module Pattern
AWS VPC Module Example
main.tf:
variables.tf:
outputs.tf:
Best Practices
- Use semantic versioning for modules
- Document all variables with descriptions
- Provide examples in examples/ directory
- Use validation blocks for input validation
- Output important attributes for module composition
- Pin provider versions in versions.tf
- Use locals for computed values
- Implement conditional resources with count/for_each
- Test modules with Terratest
- Tag all resources consistently
Reference: See references/aws-modules.md and references/oci-modules.md
Module Composition
Testing
Related Skills
multi-cloud-architecture - For architectural decisions
cost-optimization - For cost-effective designs