agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/devops/terraform/SKILL.md

terraform

Skill15 starsChanged 42 days agoMITView on GitHub

Expert HashiCorp Terraform assistance covering HCL, providers, modules, state locking, workspaces, and plan/apply workflows. Use when provisioning and managing cloud infrastructure declaratively.

23 other projects use a version of this, 2 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use codex-cli, github-cli and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • garri333Skill

    codex-cli

    OpenAI Codex CLI mastery skill for installation, authentication, terminal commands, code generation from natural language, file editing, project scaffolding, and IDE integrations. Covers GPT-5.2 Instant/Thinking tiers and shell/container execution modes.

    Also in 3 projects that use this

  • rogue-dev-studioSkill

    github-cli

    GitHub CLI authentication and workflow configuration. Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `github-cli` work when listed in TEAM.yaml or explicitly requested.

    Also in 3 projects that use this

  • nilecuiSkill

    mermaid

    Guide for creating mermaid diagrams. This skill should be used when users want to create a mermaid diagram (or update an existing diagram).

    Also in 3 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always store Terraform state in a remote backend (S3/GCS) with encryption and state locking (DynamoDB).

    line 156
  2. Very specific:

    Always generate an execution plan (terraform plan -out=tfplan) and apply the saved plan file in CI.

    line 157
  3. Very specific:

    Use default_tags at the provider level to ensure consistent tagging across all cloud resources.

    line 158
  4. Very specific:

    Commit .tfstate files or files containing secrets to version control.

    line 163
  5. Very specific:

    Use terraform apply --auto-approve in production without review and approval gates.

    line 164

“Common” is measured: kept by at least 6 in 10 of the 21 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Terraform

HashiCorp Terraform is an Infrastructure as Code (IaC) engine allowing declarative provisioning and lifecycle management of cloud resources across multi-cloud environments using HCL.

When to Use

  • Multi-Cloud Declarative Infrastructure as Code (IaC): Provisioning and managing resources across AWS, Azure, GCP, and Kubernetes.
  • State Management & Team Collaboration: Tracking real-world cloud resources via remote state backends with locking.
  • Modular Infrastructure Architecture: Writing reusable, version-controlled modules for standard cloud topologies.
  • Pre-Deployment Execution Planning: Auditing infrastructure changes with terraform plan before applying.

Quick Start

# main.tf
provider "aws" {
  region = "us-west-2"
}

resource "aws_s3_bucket" "b" {
  bucket = "my-tf-test-bucket"
  tags = {
    Name = "My bucket"
  }
}

Core Concepts

Modular Architecture with Remote State & Locking

Configuring S3 remote backend with DynamoDB state locking:

# versions.tf
terraform {
  required_version = ">= 1.9.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.50"
    }
  }

  backend "s3" {
    bucket         = "corp-terraform-state-prod"
    key            = "platform/network/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-state-lock"
    encrypt        = true
  }
}

provider "aws" {
  region = var.aws_region
  default_tags {
    tags = {
      Environment = var.environment
      ManagedBy   = "Terraform"
      Project     = "CoreInfrastructure"
    }
  }
}

Reusable VPC Module with Inputs & Outputs

Encapsulating network resources:

# modules/vpc/main.tf
resource "aws_vpc" "main" {
  cidr_block           = var.cidr_block
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = {
    Name = "${var.environment}-vpc"
  }
}

resource "aws_subnet" "public" {
  count                   = length(var.public_subnet_cidrs)
  vpc_id                  = aws_vpc.main.id
  cidr_block              = var.public_subnet_cidrs[count.index]
  availability_zone       = var.availability_zones[count.index]
  map_public_ip_on_launch = true

  tags = {
    Name = "${var.environment}-public-${count.index + 1}"
  }
}

output "vpc_id" {
  description = "The ID of the provisioned VPC"
  value       = aws_vpc.main.id
}

Terraform CLI Workflow

Planning and applying changes safely:

# Initialize providers and remote backend
terraform init

# Validate configuration syntax and variables
terraform validate

# Generate and save execution plan
terraform plan -out=tfplan.binary

# Apply verified plan atomically
terraform apply tfplan.binary

Common Patterns

S3 Backend with DynamoDB State Locking

Problem: Concurrent terraform apply executions from CI pipelines corrupting state files.

Solution: Configure remote backend with distributed state locking:

terraform {
  required_version = ">= 1.6.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }

  backend "s3" {
    bucket         = "my-terraform-state-bucket"
    key            = "production/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-locks"
    encrypt        = true
  }
}

Best Practices

Do:

  • Always store Terraform state in a remote backend (S3/GCS) with encryption and state locking (DynamoDB).
  • Always generate an execution plan (terraform plan -out=tfplan) and apply the saved plan file in CI.
  • Use default_tags at the provider level to ensure consistent tagging across all cloud resources.
  • Isolate environments using separate state files or directories (environments/prod, environments/stage), not workspaces.

Don't:

  • Commit .tfstate files or files containing secrets to version control.
  • Use terraform apply --auto-approve in production without review and approval gates.
  • Modify cloud resources manually via web consoles; out-of-band changes cause state drift.

Troubleshooting

ErrorCauseSolution
Error: Error acquiring the state lockPrevious apply was interrupted, leaving lock active in DynamoDB.Unlock after verifying no process is running: terraform force-unlock <LOCK-ID>.
Error: Resource already managed by TerraformImporting resource without configuration block or duplicate resource address.Ensure unique resource label and run terraform import <addr> <id>.
Provider configuration not presentModule using provider configuration not inherited from parent root.Pass providers explicitly: providers = { aws = aws.west }.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.