{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/terraform-module-library",
  "version": "1.0.0",
  "name": "Terraform Module Library",
  "description": "Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, ...",
  "system_prompt_fragment": "# Terraform Module Library\n\nProduction-ready Terraform module patterns for AWS, Azure, and GCP infrastructure.\n\n## Do not use this skill when\n\n- The task is unrelated to terraform module library\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources/implementation-playbook.md`.\n\n## Purpose\n\nCreate reusable, well-tested Terraform modules for common cloud infrastructure patterns across multiple cloud providers.\n\n## Use this skill when\n\n- Build reusable infrastructure components\n- Standardize cloud resource provisioning\n- Implement infrastructure as code best practices\n- Create multi-cloud compatible modules\n- Establish organizational Terraform standards\n\n## Module Structure\n\n```\nterraform-modules/\n├── aws/\n│   ├── vpc/\n│   ├── eks/\n│   ├── rds/\n│   └── s3/\n├── azure/\n│   ├── vnet/\n│   ├── aks/\n│   └── storage/\n└── gcp/\n    ├── vpc/\n    ├── gke/\n    └── cloud-sql/\n```\n\n## Standard Module Pattern\n\n```\nmodule-name/\n├── main.tf          # Main resources\n├── variables.tf     # Input variables\n├── outputs.tf       # Output values\n├── versions.tf      # Provider versions\n├── README.md        # Documentation\n├── examples/        # Usage examples\n│   └── complete/\n│       ├── main.tf\n│       └── variables.tf\n└── tests/           # Terratest files\n    └── module_test.go\n```\n\n## AWS VPC Module Example\n\n**main.tf:**\n```hcl\nresource \"aws_vpc\" \"main\" {\n  cidr_block           = var.cidr_block\n  enable_dns_hostnames = var.enable_dns_hostnames\n  enable_dns_support   = var.enable_dns_support\n\n  tags = merge(\n    {\n      Name = var.name\n    },\n    var.tags\n  )\n}\n\nresource \"aws_subnet\" \"private\" {\n  count             = length(var.private_subnet_cidrs)\n  vpc_id            = aws_vpc.main.id\n  cidr_block        = var.private_subnet_cidrs[count.index]\n  availability_zone = var.availability_zones[count.index]\n\n  tags = merge(\n    {\n      Name = \"${var.name}-private-${count.index + 1}\"\n      Tier = \"private\"\n    },\n    var.tags\n  )\n}\n\nresource \"aws_internet_gateway\" \"main\" {\n  count  = var.create_internet_gateway ? 1 : 0\n  vpc_id = aws_vpc.main.id\n\n  tags = merge(\n    {\n      Name = \"${var.name}-igw\"\n    },\n    var.tags\n  )\n}\n```\n\n**variables.tf:**\n```hcl\nvariable \"name\" {\n  description = \"Name of the VPC\"\n  type        = string\n}\n\nvariable \"cidr_block\" {\n  description = \"CIDR block for VPC\"\n  type        = string\n  validation {\n    condition     = can(regex(\"^([0-9]{1,3}\\\\.){3}[0-9]{1,3}/[0-9]{1,2}$\", var.cidr_block))\n    error_message = \"CIDR block must be valid IPv4 CIDR notation.\"\n  }\n}\n\nvariable \"availability_zones\" {\n  description = \"List of availability zones\"\n  type        = list(string)\n}\n\nvariable \"private_subnet_cidrs\" {\n  description = \"CIDR blocks for private subnets\"\n  type        = list(string)\n  default     = []\n}\n\nvariable \"enable_dns_hostnames\" {\n  description = \"Enable DNS hostnames in VPC\"\n  type        = bool\n  default     = true\n}\n\nvariable \"tags\" {\n  description = \"Additional tags\"\n  type        = map(string)\n  default     = {}\n}\n```\n\n**outputs.tf:**\n```hcl\noutput \"vpc_id\" {\n  description = \"ID of the VPC\"\n  value       = aws_vpc.main.id\n}\n\noutput \"private_subnet_ids\" {\n  description = \"IDs of private subnets\"\n  value       = aws_subnet.private[*].id\n}\n\noutput \"vpc_cidr_block\" {\n  description = \"CIDR block of VPC\"\n  value       = aws_vpc.main.cidr_block\n}\n```\n\n## Best Practices\n\n1. **Use semantic versioning** for modules\n2. **Document all variables** with descriptions\n3. **Provide examples** in examples/ directory\n4. **Use validation blocks** for input validation\n5. **Output important attributes** for module composition\n6. **Pin provider versions** in versions.tf\n7. **Use locals** for computed values\n8. **Implement conditional resources** with count/for_each\n9. **Test modules** with Terratest\n10. **Tag all resources** consistently\n\n## Module Composition\n\n```hcl\nmodule \"vpc\" {\n  source = \"../../modules/aws/vpc\"\n\n  name               = \"production\"\n  cidr_block         = \"10.0.0.0/16\"\n  availability_zones = [\"us-west-2a\", \"us-west-2b\", \"us-west-2c\"]\n\n  private_subnet_cidrs = [\n    \"10.0.1.0/24\",\n    \"10.0.2.0/24\",\n    \"10.0.3.0/24\"\n  ]\n\n  tags = {\n    Environment = \"production\"\n    ManagedBy   = \"terraform\"\n  }\n}\n\nmodule \"rds\" {\n  source = \"../../modules/aws/rds\"\n\n  identifier     = \"production-db\"\n  engine         = \"postgres\"\n  engine_version = \"15.3\"\n  instance_class = \"db.t3.large\"\n\n  vpc_id     = module.vpc.vpc_id\n  subnet_ids = module.vpc.private_subnet_ids\n\n  tags = {\n    Environment = \"production\"\n  }\n}\n```\n\n## Reference Files\n\n- `assets/vpc-module/` - Complete VPC module example\n- `assets/rds-module/` - RDS module example\n- `references/aws-modules.md` - AWS module patterns\n- `references/azure-modules.md` - Azure module patterns\n- `references/gcp-modules.md` - GCP module patterns\n\n## Testing\n\n```go\n// tests/vpc_test.go\npackage test\n\nimport (\n    \"testing\"\n    \"github.com/gruntwork-io/terratest/modules/terraform\"\n    \"github.com/stretchr/testify/assert\"\n)\n\nfunc TestVPCModule(t *testing.T) {\n    terraformOptions := &terraform.Options{\n        TerraformDir: \"../examples/complete\",\n    }\n\n    defer terraform.Destroy(t, terraformOptions)\n    terraform.InitAndApply(t, terraformOptions)\n\n    vpcID := terraform.Output(t, terraformOptions, \"vpc_id\")\n    assert.NotEmpty(t, vpcID)\n}\n```\n\n## Related Skills\n\n- `multi-cloud-architecture` - For architectural decisions\n- `cost-optimization` - For cost-effective designs",
  "applicable_domains": [
    "devops"
  ],
  "category": "devops",
  "invocation": [
    "/terraform-module-library"
  ],
  "authored_by": "claudeskills.in community",
  "source_url": "https://claudeskills.in/skill/terraform-module-library",
  "provenance": {
    "source": "claudeskills.in",
    "source_url": "https://claudeskills.in/skill/terraform-module-library",
    "license": "unknown",
    "imported_at": "2026-09-03",
    "notes": "Aggregated by claudeskills.in from community GitHub lists."
  },
  "tags": [
    "claudeskills",
    "devops"
  ],
  "lifecycle": "draft"
}