Build reusable Terraform modules for AWS, Azure, GCP

Terraform module library

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Terraform module library cover

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 Codenpx skills add wshobson/agents --skill terraform-module-library -g -a claude-code
Claude 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-library
Windows (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" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.5 KB
  • references/2 files · 2.7 KB
Read the files here
wshobson/4236bb93 files
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

  1. Use semantic versioning for modules
  2. Document all variables with descriptions
  3. Provide examples in examples/ directory
  4. Use validation blocks for input validation
  5. Output important attributes for module composition
  6. Pin provider versions in versions.tf
  7. Use locals for computed values
  8. Implement conditional resources with count/for_each
  9. Test modules with Terratest
  10. 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)
}
  • multi-cloud-architecture - For architectural decisions
  • cost-optimization - For cost-effective designs
1---
2name: terraform-module-library
3description: 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 
8Production-ready Terraform module patterns for AWS, Azure, GCP, and OCI infrastructure.
9 
10## Purpose
11 
12Create 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```
25terraform-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```
48module-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```hcl
67resource "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 
80resource "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 
95resource "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```hcl
111variable "name" {
112 description = "Name of the VPC"
113 type = string
114}
115 
116variable "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 
125variable "availability_zones" {
126 description = "List of availability zones"
127 type = list(string)
128}
129 
130variable "private_subnet_cidrs" {
131 description = "CIDR blocks for private subnets"
132 type = list(string)
133 default = []
134}
135 
136variable "enable_dns_hostnames" {
137 description = "Enable DNS hostnames in VPC"
138 type = bool
139 default = true
140}
141 
142variable "tags" {
143 description = "Additional tags"
144 type = map(string)
145 default = {}
146}
147```
148 
149**outputs.tf:**
150 
151```hcl
152output "vpc_id" {
153 description = "ID of the VPC"
154 value = aws_vpc.main.id
155}
156 
157output "private_subnet_ids" {
158 description = "IDs of private subnets"
159 value = aws_subnet.private[*].id
160}
161 
162output "vpc_cidr_block" {
163 description = "CIDR block of VPC"
164 value = aws_vpc.main.cidr_block
165}
166```
167 
168## Best Practices
169 
1701. **Use semantic versioning** for modules
1712. **Document all variables** with descriptions
1723. **Provide examples** in examples/ directory
1734. **Use validation blocks** for input validation
1745. **Output important attributes** for module composition
1756. **Pin provider versions** in versions.tf
1767. **Use locals** for computed values
1778. **Implement conditional resources** with count/for_each
1789. **Test modules** with Terratest
17910. **Tag all resources** consistently
180 
181**Reference:** See `references/aws-modules.md` and `references/oci-modules.md`
182 
183## Module Composition
184 
185```hcl
186module "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 
205module "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```go
226// tests/vpc_test.go
227package test
228 
229import (
230 "testing"
231 "github.com/gruntwork-io/terratest/modules/terraform"
232 "github.com/stretchr/testify/assert"
233)
234 
235func 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 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
SkillFrom a business idea, app ideaAzure app onboardmicrosoft/skills · by microsoftEnd-to-end orchestrator: from a business idea, app idea, or existing app to running Azure deployment with cost estimates and pre-deploy approval. Analyzes your app, auto-detects the right Azure services, scaffolds infrastructure code, and deploys — tailored to your app, not a template. Handles moving existing apps to Azure without rewriting or with minimal changes. WHEN: bring your app to Azure, plan my app, cost to run, is my code ready to deploy, deploy my app to the cloud, deploy all my services, what Azure services do I need, plan my Azure deployment, deploy my new app to Azure, one-click deploy, I have an app and want it on Azure, migrate my app to Azure, help me get started, build an app, no code yet, starter project. DO NOT USE FOR: use azd for deployment(use azure-deploy), optimizing existing costs (use cost-optimization), code readiness checks only (use azure-app-onboard-prereq).★ 3.1k GitHub starsSkillAssess whether source code is ready to deploy to AzureAzure App Onboard Prereq — Repository Evaluationmicrosoft/skills · by microsoftAssess whether source code is ready to deploy to Azure — the check BEFORE infrastructure work. Evaluates build health, app completeness, dependencies and local services, stack compatibility, and deployment feasibility. Answers questions about what your app needs before it can be deployed — frameworks, dependencies, and configuration. Checks whether dependencies are compatible and identifies deployment blockers and unsupported frameworks. WHEN: "evaluate my repo", "is my app ready to deploy", "what does my app need to deploy", "what do I need before deploying", "does my app need", "can I ship this to Azure", "scan my repo for issues", "is this app deployable", "check if my app is ready for Azure", "do I need a Dockerfile", "what's blocking my deployment", "are there any blockers", "are my dependencies compatible", "does Azure support my framework", "what needs to change before deploying", "check my app configuration".★ 3.1k GitHub starsSkillConfigure Azure API Management as an AI Gateway for AIAzure aigatewaymicrosoft/azure-skills · by microsoftConfigure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: semantic caching, token limit, content safety, load balancing, AI model governance, MCP rate limiting, jailbreak detection, add Azure OpenAI backend, add AI Foundry model, test AI gateway, LLM policies, configure AI backend, token metrics, AI cost control, convert API to MCP, import OpenAPI to gateway.★ 1.6k GitHub starsSkillQuery and analyze data in Azure Data Explorer using KQLAzure Data Explorer (Kusto) Query & Analyticsmicrosoft/azure-skills · by microsoftQuery and analyze data in Azure Data Explorer (Kusto/ADX) using KQL for log analytics, telemetry, and time series analysis. WHEN: KQL queries, Kusto database queries, Azure Data Explorer, ADX clusters, log analytics, time series data, IoT telemetry, anomaly detection.★ 1.6k GitHub starsMCPRun any server from the Docker MCP Catalog in its ownDocker MCP gatewaydocker/mcp-gateway · by dockerDocker's own CLI plugin: run any server from the Docker MCP Catalog in its own container, behind one connection, with secrets kept out of env vars.★ 1.6k GitHub starsMCPOpen infrastructure for AI agents to discover and pay eachElisymelisymlabs/elisym · by elisymlabsOpen infrastructure for AI agents to discover and pay each other★ 17 GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars