building-terraform-modules

Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1,868 stars

Best use case

building-terraform-modules is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

Teams using building-terraform-modules should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/building-terraform-modules/SKILL.md --create-dirs "https://raw.githubusercontent.com/jeremylongshore/claude-code-plugins-plus-skills/main/plugins/devops/terraform-module-builder/skills/building-terraform-modules/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/building-terraform-modules/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How building-terraform-modules Compares

Feature / Agentbuilding-terraform-modulesStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Building Terraform Modules

## Overview

Build reusable, production-ready Terraform modules with proper variable definitions, outputs, validation rules, documentation, and examples. Generate modules following HashiCorp's standard module structure for AWS, GCP, and Azure resources with security best practices, tagging conventions, and lifecycle management.

## Prerequisites

- Terraform 1.0+ installed (`terraform version`)
- Cloud provider credentials configured for the target platform
- Understanding of the infrastructure resources the module will manage
- Familiarity with HCL syntax and Terraform module conventions
- `terraform-docs` installed for automated documentation generation (optional)

## Instructions

1. Define the module scope: determine which cloud resources the module manages and its input/output contract
2. Create the standard module file structure: `main.tf`, `variables.tf`, `outputs.tf`, `versions.tf`, `locals.tf`
3. Write `versions.tf` with `required_version` and `required_providers` blocks pinned to stable versions
4. Define input variables in `variables.tf` with descriptions, types, defaults, and validation rules
5. Implement resources in `main.tf` using variables for all configurable values; use `locals` for computed values
6. Add meaningful outputs in `outputs.tf` for resource IDs, ARNs, endpoints, and connection strings
7. Implement security defaults: encryption enabled, public access blocked, least-privilege IAM, logging enabled
8. Create an `examples/` directory with at least one complete usage example showing module invocation
9. Generate documentation with `terraform-docs markdown table . > README.md`
10. Validate the module with `terraform init && terraform validate` and test with `terraform plan` using the example

## Output

- Module files: `main.tf`, `variables.tf`, `outputs.tf`, `versions.tf`, `locals.tf`
- Example usage in `examples/basic/main.tf` with realistic variable values
- Auto-generated `README.md` with inputs, outputs, and usage documentation
- `.terraform-docs.yml` configuration for documentation generation
- Optional: test files using Terratest or `terraform test` (HCL-based)

## Error Handling

| Error | Cause | Solution |
|-------|-------|---------|
| `variable validation failed` | Input value does not meet validation rule | Check the `validation` block in `variables.tf`; adjust the value or the validation regex |
| `provider not found` | Missing or wrong provider source in `versions.tf` | Add the provider to `required_providers` with correct source and version constraint |
| `circular dependency` | Resources referencing each other in a loop | Refactor to break the cycle; use `depends_on` or separate into sub-modules |
| `output references undeclared resource` | Typo in resource name or resource removed | Verify resource names in `main.tf` match output references exactly |
| `module source not found` | Incorrect module path or registry reference | Verify the `source` path is relative (e.g., `./modules/vpc`) or a valid registry address |

## Examples

- "Build a Terraform module for an AWS VPC with configurable CIDR, public/private subnets across 3 AZs, NAT gateway, and flow logs."
- "Create a GCP Cloud Run module with custom domain, IAM bindings, and auto-scaling configuration as input variables."
- "Generate a Terraform module for an S3 bucket with versioning, encryption, lifecycle rules, and access logging, with all settings as optional variables with secure defaults."

## Resources

- Terraform module registry: https://registry.terraform.io/
- Module structure guide: https://developer.hashicorp.com/terraform/language/modules/develop/structure
- terraform-docs: https://terraform-docs.io/
- Module best practices: https://developer.hashicorp.com/terraform/language/modules/develop

Related Skills

building-gitops-workflows

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute use when constructing GitOps workflows using ArgoCD or Flux. Trigger with phrases like "create GitOps workflow", "setup ArgoCD", "configure Flux", or "automate Kubernetes deployments". Generates production-ready configurations, implements best practices, and ensures security-first approach for continuous deployment.

building-cicd-pipelines

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute use when you need to work with deployment and CI/CD. This skill provides deployment automation and pipeline orchestration with comprehensive guidance and automation. Trigger with phrases like "deploy application", "create pipeline", or "automate deployment".

building-websocket-server

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build scalable WebSocket servers for real-time bidirectional communication. Use when enabling real-time bidirectional communication. Trigger with phrases like "build WebSocket server", "add real-time API", or "implement WebSocket".

building-graphql-server

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build production-ready GraphQL servers with schema design, resolvers, and subscriptions. Use when building GraphQL APIs with schemas and resolvers. Trigger with phrases like "build GraphQL API", "create GraphQL server", or "setup GraphQL".

building-api-gateway

1868
from jeremylongshore/claude-code-plugins-plus-skills

Create API gateways with routing, load balancing, rate limiting, and authentication. Use when routing and managing multiple API services. Trigger with phrases like "build API gateway", "create API router", or "setup API gateway".

building-api-authentication

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build secure API authentication systems with OAuth2, JWT, API keys, and session management. Use when implementing secure authentication flows. Trigger with phrases like "build authentication", "add API auth", or "secure the API".

building-recommendation-systems

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill empowers AI assistant to construct recommendation systems using collaborative filtering, content-based filtering, or hybrid approaches. it analyzes user preferences, item features, and interaction data to generate personalized recommendations... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

building-neural-networks

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin. it should be used when the user requests the creation of a new neural network, modification of an existing one, or assistance... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

building-classification-models

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build and evaluate classification models for supervised learning tasks with labeled data. Use when requesting "build a classifier", "create classification model", or "train classifier". Trigger with relevant phrases based on skill purpose.

building-automl-pipelines

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build automated machine learning pipelines with feature engineering, model selection, and hyperparameter tuning. Use when automating ML workflows from data preparation through model deployment. Trigger with phrases like "build automl pipeline", "automate ml workflow", or "create automated training pipeline".

terraform-state-manager

1868
from jeremylongshore/claude-code-plugins-plus-skills

Terraform State Manager - Auto-activating skill for DevOps Advanced. Triggers on: terraform state manager, terraform state manager Part of the DevOps Advanced skill category.

terraform-provider-config

1868
from jeremylongshore/claude-code-plugins-plus-skills

Terraform Provider Config - Auto-activating skill for DevOps Advanced. Triggers on: terraform provider config, terraform provider config Part of the DevOps Advanced skill category.