terraform-iac
Manages cloud infrastructure using Terraform (and OpenTofu). Use when the user wants to write Terraform configurations, provision cloud resources, manage…
от TerminalSkills★ 221 звезда на GitHub
Установить terraform-iac в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Terraform IaC
Overview
Writes, reviews, and manages Terraform/OpenTofu configurations for cloud infrastructure. Covers resource definitions, modules, state management, multi-environment setups, CI/CD integration, drift detection, and migration from manual infrastructure to code. Supports AWS, GCP, Azure, and other providers.
Instructions
1. Project Structure
Standard Terraform project layout:
infrastructure/
├── environments/
│ ├── dev/ # main.tf, variables.tf, terraform.tfvars, backend.tf
│ ├── staging/
│ └── production/
├── modules/
│ ├── networking/ # main.tf, variables.tf, outputs.tf
│ ├── compute/
│ └── database/
└── README.md
Small projects can keep main.tf, variables.tf, outputs.tf and backend.tf in one directory.
2. Writing Resources
Follow these conventions:
resource "aws_instance" "api_server" {
ami = var.ami_id
instance_type = var.instance_type
vpc_security_group_ids = [aws_security_group.api.id]
subnet_id = module.networking.private_subnet_ids[0]
tags = merge(var.common_tags, {
Name = "${var.project}-api-${var.environment}"
})
lifecycle {
create_before_destroy = true
ignore_changes = [ami] # AMI updated by CI/CD
}
}
Naming: snake_case everywhere, descriptive (web_server not ws1), files grouped by component (networking.tf, database.tf).
3. Variables and Validation
Always define type, description, and validation:
variable "environment" {
type = string
description = "Deployment environment (dev, staging, production)"
validation {
condition = contains(["dev", "staging", "production"], var.environment)
error_message = "Environment must be dev, staging, or production."
}
}
# Use locals for computed values
locals {
name_prefix = "${var.project}-${var.environment}"
is_prod = var.environment == "production"
common_tags = {
Project = var.project
Environment = var.environment
ManagedBy = "terraform"
Team = var.team
}
}
4. Modules
Write reusable modules for repeated patterns:
# modules/ecs-service/variables.tf
variable "name" { type = string }
variable "container_image" { type = string }
variable "container_port" {
type = number
default = 8080
}
variable "cpu" {
type = number
default = 256
}
variable "memory" {
type = number
default = 512
}
# modules/ecs-service/main.tf (excerpt)
data "aws_region" "current" {}
resource "aws_ecs_task_definition" "this" {
family = var.name
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
cpu = var.cpu
memory = var.memory
container_definitions = jsonencode([{
name = var.name
image = var.container_image
essential = true
portMappings = [{ containerPort = var.container_port, protocol = "tcp" }]
logConfiguration = {
logDriver = "awslogs"
options = {
"awslogs-group" = aws_cloudwatch_log_group.this.name
"awslogs-region" = data.aws_region.current.region
"awslogs-stream-prefix" = var.name
}
}
}])
}
# Usage in root
module "api" {
source = "./modules/ecs-service"
name = "api"
container_image = "123456789012.dkr.ecr.us-east-1.amazonaws.com/api:1.8.2"
cpu = 512
memory = 1024
}
Module guidelines:
- One module per logical component (networking, compute, database, monitoring)
- Always define outputs for values other modules need
- Pin module versions:
?ref=v1.2.0on git sources,version = "~> 1.2"on registry modules
5. State Management
Remote state (required for teams):
# AWS S3 backend
terraform {
backend "s3" {
bucket = "northwind-terraform-state"
key = "env/production/terraform.tfstate"
region = "us-east-1"
use_lockfile = true # native S3 locking (Terraform 1.11+, OpenTofu 1.10+)
encrypt = true
}
}
The dynamodb_table argument is deprecated; existing setups keep working, and you can migrate by enabling use_lockfile alongside it, applying, then removing the DynamoDB table. Backend blocks cannot reference variables, so pass differing values with terraform init -backend-config=production.s3.tfbackend.
State operations:
terraform state list
# Move a resource (rename without recreate)
terraform state mv aws_instance.old_name aws_instance.new_name
# Import existing infrastructure
terraform import aws_instance.api_server i-0abc123def456
# Remove from state (without destroying)
terraform state rm aws_instance.temp_server
State safety:
- Always use remote state with locking (S3
use_lockfile, GCS locks natively) - Never edit state files manually; state holds secrets in plain text, so restrict access
- Use
terraform planbefore e
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- _scores.json
FAQ
Что делает скилл terraform-iac?
Manages cloud infrastructure using Terraform (and OpenTofu). Use when the user wants to write Terraform configurations, provision cloud resources, manage state, create modules, set up multi-environment deployments, import existing infrastructure, debug plan/apply errors, migrate between providers, or implement IaC best practices. Trigger words: terraform, opentofu, infrastructure as code, IaC, tf, hcl, terraform module, terraform state, terraform plan, terraform apply, terraform import, cloud provisioning, AWS terraform, GCP terraform, Azure terraform.
Как установить скилл terraform-iac?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл terraform-iac запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…