terraform-module-library — Claude skill: Terraform modules
A skill for writing reusable Terraform modules across AWS, Azure, GCP and OCI. Useful when cloud provisioning needs a consistent shape.
/plugin marketplace add wshobson/agents
/plugin install cloud-infrastructure@claude-code-workflowsWhat terraform-module-library does
The skill lays out a module skeleton: main.tf, variables.tf, outputs.tf, versions.tf, an examples/ folder and Terratest files. Templates cover VPC, EKS, RDS and S3 on AWS, plus matching resources for Azure, GCP and OCI. Your agent reaches for them when you ask for a new module or want an existing one cleaned up.
It also spells out the rules: semantic versioning, a description on every variable, validation blocks for inputs, pinned provider versions, consistent tagging. A composition example wires a VPC module into an RDS module through vpc_id and private_subnet_ids.
Worth installing if your infrastructure lives in Terraform and copy-paste between projects has become a habit. For a single stack with a handful of resources it just adds files. You need Terraform itself, and Go if you plan to run the tests.
What it helps with
- build a reusable VPC module with private subnets
- add descriptions and validation to module variables
- wire modules together through outputs
- write a Terratest case for a module
- pin provider versions in versions.tf
Example prompts for the agent
- Create an AWS VPC Terraform module using the skill's pattern
- Add validation to the cidr_block variable
- Write a Terratest for the vpc module
How to install terraform-module-library
1Plugin marketplace
/plugin marketplace add wshobson/agents/plugin install cloud-infrastructure@claude-code-workflowsThis installs the whole cloud-infrastructure plugin with all its skills
2Skills CLI (Vercel)
npx skills add wshobson/agents --skill terraform-module-library -a claude-code3Manually: put the files in place
~/.claude/skills/terraform-module-library/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/terraform-module-library/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill terraform-module-library -a codex2Manually: put the files in place
.agents/skills/terraform-module-library/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill terraform-module-library -a cursor2Manually: put the files in place
.cursor/skills/terraform-module-library/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install wshobson/agents terraform-module-library2Manually: put the files in place
.github/skills/terraform-module-library/SKILL.mdPlatform CLI
gemini skills install https://github.com/wshobson/agents --path plugins/cloud-infrastructure/skills/terraform-module-libraryManually: put the files in place
.devin/skills/terraform-module-library/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set213
The whole set →Similar
Questions about terraform-module-library
How do I install terraform-module-library in Claude?
Use the marketplace: /plugin marketplace add wshobson/agents, then /plugin install cloud-infrastructure@claude-code-workflows. Or run npx skills add wshobson/agents --skill terraform-module-library -a claude-code.
What does terraform-module-library do?
It gives the agent Terraform module templates and conventions for AWS, Azure, GCP and OCI: file layout, variable validation, outputs, examples and tests.
Which clouds are covered?
AWS, Azure, GCP and OCI. Templates include VPC, EKS, RDS and S3 along with their equivalents on the other providers.
Source text
SKILL.md · MIT
---
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
- 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:**
```hcl
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:**
```hcl
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:**
```hcl
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
```hcl
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
```go
// 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 decisions
- `cost-optimization` - For cost-effective designs
© Seth Hobson · MIT · wshobson/agents