Terraform Module Library
Unverified●31/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add terraform-module-libraryWho is stuck, and on what
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.
The whole source
Frontmatter — 2 properties
| 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. |
| 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 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 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 | ```hcl |
| 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 | ```hcl |
| 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 | ```hcl |
| 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 | 1. **Use semantic versioning** for modules |
| 171 | 2. **Document all variables** with descriptions |
| 172 | 3. **Provide examples** in examples/ directory |
| 173 | 4. **Use validation blocks** for input validation |
| 174 | 5. **Output important attributes** for module composition |
| 175 | 6. **Pin provider versions** in versions.tf |
| 176 | 7. **Use locals** for computed values |
| 177 | 8. **Implement conditional resources** with count/for_each |
| 178 | 9. **Test modules** with Terratest |
| 179 | 10. **Tag all resources** consistently |
| 180 | |
| 181 | **Reference:** See `references/aws-modules.md` and `references/oci-modules.md` |
| 182 | |
| 183 | ## Module Composition |
| 184 | |
| 185 | ```hcl |
| 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 | ```go |
| 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 |
Reviews
Installed this one?Write the first review and take the Trailblazer badge.
Alternatives
Paper Poster (HTML): measurement-gated poster generationDEFAULT poster pipeline — build an academic conference poster (ICML/NeurIPS/ICLR/CVPR/...) as a single HTML/CSS file with measurement-driven hard gates, real paper figures, a two-hue design-token system, and print-ready PDF via headless Chromium. Use when the●····●36/40Brand Monitoring 📡Brand monitoring tool for tracking mentions across social media platforms. Monitor Reddit, Google News, YouTube, and DuckDuckGo for brand mentions. Includes sentiment analysis, trend tracking, crisis detection, and competitor comparison. No API key required fo◐····●34/40Spark Memory & Thermal OpsManage unified memory and thermals during long-running ML jobs on NVIDIA DGX Spark. Use when planning memory headroom for a training run on GB10, when a job OOMs on unified memory, or when monitoring temperature and power during multi-hour training.◐····●32/40Secrets ManagementImplement secure secrets management for CI/CD pipelines using Vault, AWS Secrets Manager, or native platform solutions. Use when handling sensitive credentials, rotating secrets, or securing CI/CD environments.◐····●32/40