Build reusable Terraform modules for AWS, Azure, GCP
Terraform module library

Build reusable Terraform modules for AWS, Azure, GCP, and OCI infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC…
--- name: terraform-module-library description: Build reusable Terraform modules for AWS, Azure, GCP, and OCI infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components. --- # 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
Overview
Production-ready Terraform module patterns for AWS, Azure, GCP, and OCI infrastructure.
Manual install (npx, ZIP)
Claude Code
npx skills add wshobson/agents --skill terraform-module-library -g -a claude-codeClaude Code (manual)
mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/cloud-infrastructure/skills/terraform-module-libraryWindows (PowerShell)
New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/e2d8c7f6d87d8440f875/terraform-module-library.zip" -OutFile "$env:TEMP\terraform-module-library.zip"; Expand-Archive "$env:TEMP\terraform-module-library.zip" -DestinationPath "$HOME\.claude\skills" -ForceClaude.ai / desktop
Codex, Cursor, other agents
Connects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md5.5 KBreferences/2 files · 2.7 KB
Read the files here
SKILL.md
Show the full text252 lines
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
terraform-modules/
├── aws/
│ ├── vpc/
│ ├── eks/
│ ├── rds/
│ └── s3/
├── azure/
│ ├── vnet/
│ ├── aks/
│ └── storage/
├── gcp/
│ ├── vpc/
│ ├── gke/
│ └── cloud-sql/
└── oci/
├── vcn/
├── oke/
└── object-storage/
Standard Module Pattern
module-name/
├── main.tf # Main resources
├── variables.tf # Input variables
├── outputs.tf # Output values
├── versions.tf # Provider versions
├── README.md # Documentation
├── examples/ # Usage examples
│ └── complete/
│ ├── main.tf
│ └── variables.tf
└── tests/ # Terratest files
└── module_test.go
AWS VPC Module Example
main.tf:
resource "aws_vpc" "main" {
cidr_block = var.cidr_block
enable_dns_hostnames = var.enable_dns_hostnames
enable_dns_support = var.enable_dns_support
tags = merge(
{
Name = var.name
},
var.tags
)
}
resource "aws_subnet" "private" {
count = length(var.private_subnet_cidrs)
vpc_id = aws_vpc.main.id
cidr_block = var.private_subnet_cidrs[count.index]
availability_zone = var.availability_zones[count.index]
tags = merge(
{
Name = "${var.name}-private-${count.index + 1}"
Tier = "private"
},
var.tags
)
}
resource "aws_internet_gateway" "main" {
count = var.create_internet_gateway ? 1 : 0
vpc_id = aws_vpc.main.id
tags = merge(
{
Name = "${var.name}-igw"
},
var.tags
)
}
variables.tf:
variable "name" {
description = "Name of the VPC"
type = string
}
variable "cidr_block" {
description = "CIDR block for VPC"
type = string
validation {
condition = can(regex("^([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}$", var.cidr_block))
error_message = "CIDR block must be valid IPv4 CIDR notation."
}
}
variable "availability_zones" {
description = "List of availability zones"
type = list(string)
}
variable "private_subnet_cidrs" {
description = "CIDR blocks for private subnets"
type = list(string)
default = []
}
variable "enable_dns_hostnames" {
description = "Enable DNS hostnames in VPC"
type = bool
default = true
}
variable "tags" {
description = "Additional tags"
type = map(string)
default = {}
}
outputs.tf:
output "vpc_id" {
description = "ID of the VPC"
value = aws_vpc.main.id
}
output "private_subnet_ids" {
description = "IDs of private subnets"
value = aws_subnet.private[*].id
}
output "vpc_cidr_block" {
description = "CIDR block of VPC"
value = aws_vpc.main.cidr_block
}
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
module "vpc" {
source = "../../modules/aws/vpc"
name = "production"
cidr_block = "10.0.0.0/16"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
private_subnet_cidrs = [
"10.0.1.0/24",
"10.0.2.0/24",
"10.0.3.0/24"
]
tags = {
Environment = "production"
ManagedBy = "terraform"
}
}
module "rds" {
source = "../../modules/aws/rds"
identifier = "production-db"
engine = "postgres"
engine_version = "15.3"
instance_class = "db.t3.large"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnet_ids
tags = {
Environment = "production"
}
}
Testing
// tests/vpc_test.go
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)
func TestVPCModule(t *testing.T) {
terraformOptions := &terraform.Options{
TerraformDir: "../examples/complete",
}
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
vpcID := terraform.Output(t, terraformOptions, "vpc_id")
assert.NotEmpty(t, vpcID)
}
Related Skills
multi-cloud-architecture- For architectural decisionscost-optimization- For cost-effective designs
| 1 | |
| 2 | name terraform-module-library |
| 3 | description Build reusable Terraform modules for AWS, Azure, GCP, and OCI infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components. |
| 4 | |
| 5 | |
| 6 | # Terraform Module Library |
| 7 | |
| 8 | Production-ready Terraform module patterns for AWS, Azure, GCP, and OCI infrastructure. |
| 9 | |
| 10 | ## Purpose |
| 11 | |
| 12 | Create reusable, well-tested Terraform modules for common cloud infrastructure patterns across multiple cloud providers. |
| 13 | |
| 14 | ## When to Use |
| 15 | |
| 16 | Build reusable infrastructure components |
| 17 | Standardize cloud resource provisioning |
| 18 | Implement infrastructure as code best practices |
| 19 | Create multi-cloud compatible modules |
| 20 | Establish organizational Terraform standards |
| 21 | |
| 22 | ## Module Structure |
| 23 | |
| 24 | |
| 25 | terraform-modules/ |
| 26 | ├── aws/ |
| 27 | │ ├── vpc/ |
| 28 | │ ├── eks/ |
| 29 | │ ├── rds/ |
| 30 | │ └── s3/ |
| 31 | ├── azure/ |
| 32 | │ ├── vnet/ |
| 33 | │ ├── aks/ |
| 34 | │ └── storage/ |
| 35 | ├── gcp/ |
| 36 | │ ├── vpc/ |
| 37 | │ ├── gke/ |
| 38 | │ └── cloud-sql/ |
| 39 | └── oci/ |
| 40 | ├── vcn/ |
| 41 | ├── oke/ |
| 42 | └── object-storage/ |
| 43 | |
| 44 | |
| 45 | ## Standard Module Pattern |
| 46 | |
| 47 | |
| 48 | module-name/ |
| 49 | ├── main.tf # Main resources |
| 50 | ├── variables.tf # Input variables |
| 51 | ├── outputs.tf # Output values |
| 52 | ├── versions.tf # Provider versions |
| 53 | ├── README.md # Documentation |
| 54 | ├── examples/ # Usage examples |
| 55 | │ └── complete/ |
| 56 | │ ├── main.tf |
| 57 | │ └── variables.tf |
| 58 | └── tests/ # Terratest files |
| 59 | └── module_test.go |
| 60 | |
| 61 | |
| 62 | ## AWS VPC Module Example |
| 63 | |
| 64 | **main.tf:** |
| 65 | |
| 66 | |
| 67 | resource "aws_vpc" "main" { |
| 68 | cidr_block = var.cidr_block |
| 69 | enable_dns_hostnames = var.enable_dns_hostnames |
| 70 | enable_dns_support = var.enable_dns_support |
| 71 | |
| 72 | tags = merge( |
| 73 | { |
| 74 | Name = var.name |
| 75 | }, |
| 76 | var.tags |
| 77 | ) |
| 78 | } |
| 79 | |
| 80 | resource "aws_subnet" "private" { |
| 81 | count = length(var.private_subnet_cidrs) |
| 82 | vpc_id = aws_vpc.main.id |
| 83 | cidr_block = var.private_subnet_cidrs[count.index] |
| 84 | availability_zone = var.availability_zones[count.index] |
| 85 | |
| 86 | tags = merge( |
| 87 | { |
| 88 | Name = "${var.name}-private-${count.index + 1}" |
| 89 | Tier = "private" |
| 90 | }, |
| 91 | var.tags |
| 92 | ) |
| 93 | } |
| 94 | |
| 95 | resource "aws_internet_gateway" "main" { |
| 96 | count = var.create_internet_gateway ? 1 : 0 |
| 97 | vpc_id = aws_vpc.main.id |
| 98 | |
| 99 | tags = merge( |
| 100 | { |
| 101 | Name = "${var.name}-igw" |
| 102 | }, |
| 103 | var.tags |
| 104 | ) |
| 105 | } |
| 106 | |
| 107 | |
| 108 | **variables.tf:** |
| 109 | |
| 110 | |
| 111 | variable "name" { |
| 112 | description = "Name of the VPC" |
| 113 | type = string |
| 114 | } |
| 115 | |
| 116 | variable "cidr_block" { |
| 117 | description = "CIDR block for VPC" |
| 118 | type = string |
| 119 | validation { |
| 120 | condition = can(regex("^([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}$", var.cidr_block)) |
| 121 | error_message = "CIDR block must be valid IPv4 CIDR notation." |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | variable "availability_zones" { |
| 126 | description = "List of availability zones" |
| 127 | type = list(string) |
| 128 | } |
| 129 | |
| 130 | variable "private_subnet_cidrs" { |
| 131 | description = "CIDR blocks for private subnets" |
| 132 | type = list(string) |
| 133 | default = [] |
| 134 | } |
| 135 | |
| 136 | variable "enable_dns_hostnames" { |
| 137 | description = "Enable DNS hostnames in VPC" |
| 138 | type = bool |
| 139 | default = true |
| 140 | } |
| 141 | |
| 142 | variable "tags" { |
| 143 | description = "Additional tags" |
| 144 | type = map(string) |
| 145 | default = {} |
| 146 | } |
| 147 | |
| 148 | |
| 149 | **outputs.tf:** |
| 150 | |
| 151 | |
| 152 | output "vpc_id" { |
| 153 | description = "ID of the VPC" |
| 154 | value = aws_vpc.main.id |
| 155 | } |
| 156 | |
| 157 | output "private_subnet_ids" { |
| 158 | description = "IDs of private subnets" |
| 159 | value = aws_subnet.private[*].id |
| 160 | } |
| 161 | |
| 162 | output "vpc_cidr_block" { |
| 163 | description = "CIDR block of VPC" |
| 164 | value = aws_vpc.main.cidr_block |
| 165 | } |
| 166 | |
| 167 | |
| 168 | ## Best Practices |
| 169 | |
| 170 | **Use semantic versioning** for modules |
| 171 | **Document all variables** with descriptions |
| 172 | **Provide examples** in examples/ directory |
| 173 | **Use validation blocks** for input validation |
| 174 | **Output important attributes** for module composition |
| 175 | **Pin provider versions** in versions.tf |
| 176 | **Use locals** for computed values |
| 177 | **Implement conditional resources** with count/for_each |
| 178 | **Test modules** with Terratest |
| 179 | **Tag all resources** consistently |
| 180 | |
| 181 | **Reference:** See `references/aws-modules.md` and `references/oci-modules.md` |
| 182 | |
| 183 | ## Module Composition |
| 184 | |
| 185 | |
| 186 | module "vpc" { |
| 187 | source = "../../modules/aws/vpc" |
| 188 | |
| 189 | name = "production" |
| 190 | cidr_block = "10.0.0.0/16" |
| 191 | availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] |
| 192 | |
| 193 | private_subnet_cidrs = [ |
| 194 | "10.0.1.0/24", |
| 195 | "10.0.2.0/24", |
| 196 | "10.0.3.0/24" |
| 197 | ] |
| 198 | |
| 199 | tags = { |
| 200 | Environment = "production" |
| 201 | ManagedBy = "terraform" |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | module "rds" { |
| 206 | source = "../../modules/aws/rds" |
| 207 | |
| 208 | identifier = "production-db" |
| 209 | engine = "postgres" |
| 210 | engine_version = "15.3" |
| 211 | instance_class = "db.t3.large" |
| 212 | |
| 213 | vpc_id = module.vpc.vpc_id |
| 214 | subnet_ids = module.vpc.private_subnet_ids |
| 215 | |
| 216 | tags = { |
| 217 | Environment = "production" |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | |
| 222 | |
| 223 | ## Testing |
| 224 | |
| 225 | |
| 226 | // tests/vpc_test.go |
| 227 | package test |
| 228 | |
| 229 | import ( |
| 230 | "testing" |
| 231 | "github.com/gruntwork-io/terratest/modules/terraform" |
| 232 | "github.com/stretchr/testify/assert" |
| 233 | ) |
| 234 | |
| 235 | func TestVPCModule(t *testing.T) { |
| 236 | terraformOptions := &terraform.Options{ |
| 237 | TerraformDir: "../examples/complete", |
| 238 | } |
| 239 | |
| 240 | defer terraform.Destroy(t, terraformOptions) |
| 241 | terraform.InitAndApply(t, terraformOptions) |
| 242 | |
| 243 | vpcID := terraform.Output(t, terraformOptions, "vpc_id") |
| 244 | assert.NotEmpty(t, vpcID) |
| 245 | } |
| 246 | |
| 247 | |
| 248 | ## Related Skills |
| 249 | |
| 250 | `multi-cloud-architecture` - For architectural decisions |
| 251 | `cost-optimization` - For cost-effective designs |
| 252 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
SkillFrom a business idea, app ideaAzure app onboard
SkillAssess whether source code is ready to deploy to AzureAzure App Onboard Prereq — Repository Evaluation
SkillConfigure Azure API Management as an AI Gateway for AIAzure aigateway
SkillQuery and analyze data in Azure Data Explorer using KQLAzure Data Explorer (Kusto) Query & Analytics
MCPRun any server from the Docker MCP Catalog in its ownDocker MCP gateway
MCPOpen infrastructure for AI agents to discover and pay eachElisymMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns