terraform
Use when the user asks for a Terraform module (for example a VPC with remote state), state backends and locking, workspaces, terraform plan in CI, module…
от j4flmao★ 47 звёзд на GitHub
Установить terraform в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Terraform Patterns
Purpose
Define and enforce Terraform infrastructure provisioning patterns with module design, state management, and CI/CD integration.
Agent Protocol
Trigger
User request includes: terraform, tf, iac, infrastructure as code, hcl, terraform module, terraform state, terraform workspace, terraform backend, terragrunt.
Input Context
- Cloud provider (AWS, GCP, Azure)
- Current IaC state (if any)
- Team structure (who manages infrastructure)
- State storage requirements
- Compliance requirements
Output Artifact
A markdown document containing:
- Module structure (directory layout, naming)
- State management strategy (remote backend, locking)
- Workspace/environment strategy
- Module design (input/output conventions, versioning)
- CI/CD pipeline integration
- Policy as code (Sentinel, OPA/Rego)
- Secret management
Response Format
Produce the artifact directly. No preamble, no postamble, no explanations. No filler, no hedging, no transitions. Strip articles a/an/the where unambiguous. Compress output — why use many token when few do trick.
Completion Criteria
- Module directory structure documented
- Backend configuration with state locking
- Workspace or directory strategy per environment
- Module input/output conventions defined
- CI/CD pipeline steps for plan/apply
Max Response Length
4096 tokens
Decision Tree: Directory Structure vs Workspaces vs Terragrunt
| Strategy | When | Pros | Cons |
|---|---|---|---|
| Directory per env | Production workloads, different configs | Clear separation, parallel applies | Config duplication |
| Workspaces | Dev/test, same config | DRY, minimal files | Accidental cross-env changes |
| Terragrunt | Multi-module dependencies | DRY, dependency resolution | Additional tooling, complexity |
Rule: Prefer directory per environment for production. Workspaces for dev/test only.
Workflow
Step 1: Set Up Repository Structure
terraform/
├── environments/
│ ├── production/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ │ ├── terraform.tfvars
│ │ ├── backend.hcl
│ │ └── provider.tf
│ ├── staging/
│ │ └── ...
│ └── development/
│ └── ...
├── modules/
│ ├── eks/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ │ └── README.md
│ ├── rds/
│ │ └── ...
│ ├── vpc/
│ │ └── ...
│ └── iam/
│ └── ...
├── policies/
│ ├── required_tags.rego
│ ├── allowed_instance_types.rego
│ └── enforce_encryption.rego
├── scripts/
│ └── plan-apply.sh
├── versions.tf
├── terragrunt.hcl
└── README.md
Step 2: Configure Backend
# environments/production/backend.hcl
bucket = "tf-state-prod"
key = "production/terraform.tfstate"
region = "us-east-1"
encrypt = true
use_lockfile = true # S3-native locking (Terraform >= 1.10); dynamodb_table is deprecated
# environments/production/main.tf
terraform {
backend "s3" {
# Use -backend-config=backend.hcl for partial config
}
required_version = ">= 1.10"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0" # AWS provider 6.x is current (released mid-2025)
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.0"
}
}
}
Step 3: Backend Selection Comparison
| Backend | State Locking | Encryption | Best For |
|---|---|---|---|
| S3 + DynamoDB | Yes (DynamoDB) | SSE-S3/KMS | AWS-native teams |
| GCS | Yes (native) | AES256/CMEK | GCP-native teams |
| AzureRM | Yes (Blob lease) | SSE | Azure-native teams |
| HCP Terraform (formerly Terraform Cloud) | Yes (native) | At rest + in transit | Team collaboration, remote runs |
| Consul | Yes (session) | TLS | Self-hosted, simple |
| local | No | No | Personal projects only |
Step 4: Design Modules — VPC Example
# modules/vpc/main.tf
variable "name" {
description = "VPC name"
type = string
}
variable "cidr_block" {
description = "CIDR block for VPC"
type = string
validation {
condition = can(cidrsubnet(var.cidr_block, 0, 0))
error_message = "Must be a valid CIDR block."
}
}
variable "azs" {
description = "Availability zones"
type = list(string)
}
variable "enable_nat_gateway" {
description = "Enable NAT gateway"
type = bool
default = true
}
variable "tags" {
description = "Resource tags"
type = map(string)
default = {}
}
resource "aws_vpc" "this" {
cidr_block = var.cidr_block
enable_dns_hostnames = true
enable_dns_support = true
tags = merge(var.tags, {
Name = var.name
})
}
resource "aws_subnet" "public" {
count = length(var.azs)
vpc_id = aws_vpc.this.id
cidr_block = cidrsubnet(var.cidr_block, 8, count.index)
availability_zone = var.azs[count.index]
map_public
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/merged-terraform-patterns.md
- references/modules-composition.md
- references/state-management.md
- references/terraform-advanced.md
- references/terraform-ecosystem.md
- references/terraform-fundamentals.md
- references/terraform-modules.md
- references/terraform-state.md
- references/terraform-testing.md
FAQ
Что делает скилл terraform?
Use when the user asks for a Terraform module (for example a VPC with remote state), state backends and locking, workspaces, terraform plan in CI, module versioning, import and moved blocks, or OpenTofu. Produces module layouts, backend configs and CI review flows. Not for Pulumi (use devops-pulumi) or configuration management (use ansible).
Как установить скилл terraform?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл terraform запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
AnthropicThe scan that the plugin's GitHub Action runs.
azure-static-web-apps
GitHubHelps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
ai-ready
GitHubMake any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
aws-cdk-python-setup
GitHubSetup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…