terraform-project-generator

Generate complete Terraform project structure with main.tf, variables.tf, outputs.tf, backend.tf, and terraform.tf following best practices

5 stars

Best use case

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

Generate complete Terraform project structure with main.tf, variables.tf, outputs.tf, backend.tf, and terraform.tf following best practices

Teams using terraform-project-generator 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/terraform-project-generator/SKILL.md --create-dirs "https://raw.githubusercontent.com/GuicedEE/ai-rules/main/skills/.curated/terraform-project-generator/SKILL.md"

Manual Installation

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

How terraform-project-generator Compares

Feature / Agentterraform-project-generatorStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generate complete Terraform project structure with main.tf, variables.tf, outputs.tf, backend.tf, and terraform.tf following best practices

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.

SKILL.md Source

# Terraform Project Generator

You are a Terraform project scaffolding expert. When this skill is invoked, you help users generate complete, production-ready Terraform project structures following HashiCorp best practices.

## Your Task

When a user requests a new Terraform project:

1. **Gather Requirements**:
   - Provider(s) to use (azurerm, aws, google, etc.)
   - Resources to include
   - Backend type (local, azurerm, s3, gcs)
   - Whether to include examples

2. **Generate Standard File Structure**:
   ```
   project-name/
   ├── main.tf           # Resource definitions
   ├── variables.tf      # Input variables
   ├── outputs.tf        # Output values
   ├── terraform.tf      # Terraform and provider config
   ├── backend.tf        # Backend configuration
   ├── .gitignore        # Git ignore file
   └── README.md         # Project documentation
   ```

3. **Follow Best Practices**:
   - Use snake_case for resource names
   - Add descriptions to all variables
   - Include variable validation where appropriate
   - Use consistent naming conventions
   - Add helpful comments
   - Set appropriate provider versions

## File Templates

### terraform.tf
```hcl
terraform {
  required_version = ">= 1.6"

  required_providers {
    {provider} = {
      source  = "hashicorp/{provider}"
      version = "~> {major_version}"
    }
  }
}

provider "{provider}" {
  # Provider-specific configuration
}
```

### backend.tf
For Azure (azurerm):
```hcl
terraform {
  backend "azurerm" {
    resource_group_name  = "terraform-state-rg"
    storage_account_name = "tfstate${random_suffix}"
    container_name       = "tfstate"
    key                  = "terraform.tfstate"
  }
}
```

For AWS (s3):
```hcl
terraform {
  backend "s3" {
    bucket         = "terraform-state-bucket"
    key            = "terraform.tfstate"
    region         = "us-east-1"
    encrypt        = true
    dynamodb_table = "terraform-locks"
  }
}
```

### variables.tf
```hcl
variable "environment" {
  description = "Environment name (e.g., dev, staging, prod)"
  type        = string

  validation {
    condition     = contains(["dev", "staging", "prod"], var.environment)
    error_message = "Environment must be dev, staging, or prod."
  }
}

variable "location" {
  description = "Azure region where resources will be created"
  type        = string
  default     = "eastus"
}

variable "tags" {
  description = "Tags to apply to all resources"
  type        = map(string)
  default     = {}
}
```

### outputs.tf
```hcl
output "resource_group_id" {
  description = "ID of the resource group"
  value       = azurerm_resource_group.main.id
}

output "resource_group_name" {
  description = "Name of the resource group"
  value       = azurerm_resource_group.main.name
}
```

### main.tf
```hcl
# Resource Group
resource "azurerm_resource_group" "main" {
  name     = "rg-${var.environment}-${var.project_name}"
  location = var.location
  tags     = var.tags
}
```

### .gitignore
```
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files
*.tfvars
*.tfvars.json

# Ignore override files
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore CLI configuration files
.terraformrc
terraform.rc

# Ignore plan files
*.tfplan
```

### README.md
```markdown
# {Project Name}

{Project Description}

## Prerequisites

- Terraform >= 1.6
- {Provider} CLI configured
- Appropriate access credentials

## Usage

1. Initialize Terraform:
   ```bash
   terraform init
   ```

2. Review the plan:
   ```bash
   terraform plan
   ```

3. Apply the configuration:
   ```bash
   terraform apply
   ```

## Variables

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|----------|
| {var_name} | {description} | {type} | {default} | {yes/no} |

## Outputs

| Name | Description |
|------|-------------|
| {output_name} | {description} |
```

## Interactive Setup

Ask the user for:

1. **Project name**: What should this project be called?
2. **Provider**: Which cloud provider? (azurerm/aws/google)
3. **Backend**: Where to store state? (local/azurerm/s3/gcs)
4. **Resources**: What resources to include initially?
5. **Environment**: Development, staging, or production?

## Naming Conventions

Follow these patterns:

- **Resource Groups**: `rg-{environment}-{purpose}`
- **Storage Accounts**: `st{environment}{purpose}`
- **Virtual Networks**: `vnet-{environment}-{purpose}`
- **Subnets**: `snet-{environment}-{purpose}`
- **Virtual Machines**: `vm-{environment}-{purpose}`

## Script Integration

If `scripts/generate-project.js` exists, use it:

```bash
node scripts/generate-project.js \
  --name myproject \
  --provider azurerm \
  --backend azurerm \
  --output ./myproject
```

## Examples

**Example 1**: Azure web application infrastructure
- Resource group
- App Service Plan
- App Service
- Application Insights

**Example 2**: AWS three-tier architecture
- VPC with subnets
- Application Load Balancer
- Auto Scaling Group
- RDS Database

## Best Practices Checklist

- [ ] All variables have descriptions
- [ ] Variable validation where appropriate
- [ ] Outputs for all important resources
- [ ] Consistent naming convention
- [ ] Provider version pinned
- [ ] Backend configured for team use
- [ ] .gitignore includes sensitive files
- [ ] README with usage instructions

Related Skills

terraform-validator

5
from GuicedEE/ai-rules

Validate Terraform code for syntax errors, best practices, security issues, and compliance with standards

terraform-state-manager

5
from GuicedEE/ai-rules

Analyze, inspect, and safely manipulate Terraform state files with drift detection and resource management

terraform-security-scanner

5
from GuicedEE/ai-rules

Comprehensive security scanning for Terraform code including secrets detection, compliance checks, and vulnerability assessment

terraform-resource-fetch

5
from GuicedEE/ai-rules

Fetch latest Terraform provider resources and documentation from Terraform Registry

terraform-plan-analyzer

5
from GuicedEE/ai-rules

Parse, explain, and analyze terraform plan output for impact assessment, cost estimation, and risk evaluation

terraform-module-scaffold

5
from GuicedEE/ai-rules

Create production-ready, reusable Terraform modules with complete documentation, examples, and tests

terraform-doc-generator

5
from GuicedEE/ai-rules

Auto-generate comprehensive README.md documentation for Terraform modules with usage examples, inputs, outputs, and requirements

terraform-code-generator

5
from GuicedEE/ai-rules

Auto-generate Terraform resource blocks by fetching latest schemas from Terraform Registry in real-time

skill-installer

5
from GuicedEE/ai-rules

Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).

skill-creator

5
from GuicedEE/ai-rules

Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Codex's capabilities with specialized knowledge, workflows, or tool integrations.

jwebmp-webawesome

5
from GuicedEE/ai-rules

WebAwesome icon integration for JWebMP — modern, open-source icon library. Provides 1,500+ icons with solid/regular styles, sizing, rotation, animation, and CSS utilities. Drop-in FontAwesome alternative with fresh designs. Use when working with WebAwesome icons, modern icon designs, or as FontAwesome alternative in JWebMP applications.

jwebmp-webawesome-pro

5
from GuicedEE/ai-rules

WebAwesome Pro integration for JWebMP with premium icons and features. Extends jwebmp-webawesome with additional styles, premium icons, and advanced features. Use when working with WebAwesome Pro icons or premium WebAwesome features in JWebMP applications.