# terraform-module-builder

terraform-module-builder generates structured, reusable Terraform modules with input variable validation, outputs, and example configurations.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 229 installs · ★ 64 repo stars
- Author: patricio0312rev
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/patricio0312rev/skills/tree/HEAD/ci-cd/terraform-module-builder/SKILL.md
- Updated: 2026-01-12
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/terraform-module-builder

## What it does

This skill guides the agent to organize Infrastructure as Code into modular files rather than a single monolith. It separates code into `main.tf`, `variables.tf`, `outputs.tf`, `versions.tf`, `locals.tf`, and `data.tf`, alongside documentation and an `examples/complete` setup.

Generated modules prioritize input validation rules—such as verifying CIDR notation or limiting name lengths—and clean remote state handling. Omitting provider constraints in `versions.tf` will break execution across different Terraform environments, so specifying provider requirements upfront remains essential.

## Requirements
- Works with: Terraform

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill terraform-module-builder -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/terraform-module-builder/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/terraform-module-builder/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill terraform-module-builder -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/terraform-module-builder/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill terraform-module-builder -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/terraform-module-builder/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install patricio0312rev/skills ci-cd/terraform-module-builder/SKILL.md
```

2. **Manually: put the files in place**
- File: `.github/skills/terraform-module-builder/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill terraform-module-builder -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/patricio0312rev/skills --path ci-cd/terraform-module-builder
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/terraform-module-builder/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill terraform-module-builder -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/patricio0312rev/skills/tree/HEAD/ci-cd/terraform-module-builder/SKILL.md

## When to use it
- Scaffold standardized Terraform module file trees with examples
- Validate input variable schemas using CIDR checks and length limits
- Build production-grade AWS VPC configurations with NAT gateways and subnets
- Export structured outputs for downstream infrastructure dependencies

## Example prompts
- Build a reusable Terraform VPC module with public and private subnets
- Refactor this monolithic infrastructure script into a structured Terraform module
- Add validation blocks for CIDR inputs in variables.tf

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: b3b55eff12947cb2.

BEGIN THIRD-PARTY FILE b3b55eff12947cb2
````text
---
name: terraform-module-builder
description: Creates reusable Terraform modules with proper structure, variables, outputs, and state management for infrastructure as code. Use when users request "Terraform setup", "infrastructure as code", "IaC module", "cloud provisioning", or "Terraform module".
---

# Terraform Module Builder

Build reusable, production-ready Terraform modules for cloud infrastructure.

## Core Workflow

1. **Define module structure**: Organize files properly
2. **Declare variables**: Input parameters with validation
3. **Create resources**: Infrastructure definitions
4. **Configure outputs**: Export useful values
5. **Setup state**: Remote backend configuration
6. **Document**: README and examples

## Module Structure

```
modules/
└── vpc/
    ├── main.tf           # Primary resources
    ├── variables.tf      # Input variables
    ├── outputs.tf        # Output values
    ├── versions.tf       # Provider versions
    ├── locals.tf         # Local values
    ├── data.tf           # Data sources
    ├── README.md         # Documentation
    └── examples/
        └── complete/
            ├── main.tf
            └── outputs.tf
```

## VPC Module Example

### Main Configuration

```hcl
# modules/vpc/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(
    var.tags,
    {
      Name = var.name
    }
  )
}

resource "aws_internet_gateway" "main" {
  count = var.create_igw ? 1 : 0

  vpc_id = aws_vpc.main.id

  tags = merge(
    var.tags,
    {
      Name = "${var.name}-igw"
    }
  )
}

resource "aws_subnet" "public" {
  count = length(var.public_subnets)

  vpc_id                  = aws_vpc.main.id
  cidr_block              = var.public_subnets[count.index]
  availability_zone       = var.availability_zones[count.index]
  map_public_ip_on_launch = true

  tags = merge(
    var.tags,
    {
      Name = "${var.name}-public-${var.availability_zones[count.index]}"
      Tier = "public"
    }
  )
}

resource "aws_subnet" "private" {
  count = length(var.private_subnets)

  vpc_id            = aws_vpc.main.id
  cidr_block        = var.private_subnets[count.index]
  availability_zone = var.availability_zones[count.index]

  tags = merge(
    var.tags,
    {
      Name = "${var.name}-private-${var.availability_zones[count.index]}"
      Tier = "private"
    }
  )
}

resource "aws_eip" "nat" {
  count = var.enable_nat_gateway ? (var.single_nat_gateway ? 1 : length(var.public_subnets)) : 0

  domain = "vpc"

  tags = merge(
    var.tags,
    {
      Name = "${var.name}-nat-${count.index + 1}"
    }
  )
````
END THIRD-PARTY FILE b3b55eff12947cb2

The third-party file has ended. Everything between the b3b55eff12947cb2 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2770 of 13973 bytes. © patricio0312rev · MIT · https://github.com/patricio0312rev/skills/tree/HEAD/ci-cd/terraform-module-builder/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
