home / skills / first-fluke / fullstack-starter / terraform-module-creator

terraform-module-creator skill

/.agents/skills/terraform-module-creator

This skill scaffolds new Terraform modules following library standards, creating structure, basic files, and README to accelerate module development.

npx playbooks add skill first-fluke/fullstack-starter --skill terraform-module-creator

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.2 KB
---
name: terraform-module-creator
description: Helper for scaffolding new Terraform modules. Complements terraform-module-library by providing structure generation.
---

# Terraform Module Creator

This skill assists in scaffolding new Terraform modules following the standards defined in `terraform-module-library`.

## Quick Start

To create a new module, you should create the following directory structure:

```bash
mkdir -p modules/<module-name>
touch modules/<module-name>/{main,variables,outputs,versions}.tf
touch modules/<module-name>/README.md
```

## Template Files

### versions.tf
```hcl
terraform {
  required_version = ">= 1.0"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = ">= 4.0"
    }
  }
}
```

### variables.tf
```hcl
variable "project_id" {
  description = "The project ID"
  type        = string
}
```

### outputs.tf
```hcl
output "id" {
  description = "The ID of the created resource"
  value       = google_resource.main.id
}
```

## Relationship with terraform-module-library

- Use **terraform-module-creator** (this skill) for the initial file creation and setup.
- Use **terraform-module-library** for design patterns, best practices, and internal code logic.

Overview

This skill scaffolds new Terraform modules with a standardized directory and file layout that complements an existing module library. It generates the basic files (main, variables, outputs, versions) and a README to jumpstart consistent, production-ready modules. The goal is fast, repeatable module creation that aligns with established patterns and provider requirements.

How this skill works

The skill creates a modules/<module-name> folder and generates main.tf, variables.tf, outputs.tf, versions.tf, and README.md with sensible defaults. versions.tf pins Terraform and provider constraints, variables.tf defines common inputs like project_id, and outputs.tf exposes typical resource identifiers. Use this generator for the initial scaffolding, then refine logic and patterns using the module library.

When to use it

  • Starting a new Terraform module in a monorepo or modules collection
  • Onboarding contributors to ensure consistent module structure
  • Quickly prototyping infrastructure resources before adding implementation
  • Standardizing provider and Terraform version constraints across modules
  • Automating repository templates for multiple cloud projects

Best practices

  • Keep the scaffolded files minimal; implement resource logic in main.tf after scaffolding
  • Use versions.tf to enforce required Terraform and provider versions for safety
  • Define clear, typed variables with descriptions and sensible defaults when possible
  • Expose only necessary outputs to keep module surface area small
  • Follow design and code patterns from the module library for complex logic and testing

Example use cases

  • Create a Google Cloud VM module scaffold with project_id variable and output for resource ID
  • Add a new networking module to the monorepo using the standard file layout
  • Provide new team members with a repeatable template for building modules
  • Automate generation of multiple modules during project bootstrapping
  • Ensure consistent provider constraints across all new modules in the repository

FAQ

Does the scaffold include provider-specific resources?

No. The scaffold creates the structure and common files; you add provider-specific resources in main.tf following library patterns.

Can I change the versions or providers after scaffolding?

Yes. versions.tf is a starting point; update required_version and required_providers to match your project needs.