terraform-engineer by 404kidwiz/claude-supercode-skills
npx skills add https://github.com/404kidwiz/claude-supercode-skills --skill terraform-engineer提供基础设施即代码(IaC)专业知识,专注于 Terraform 和 OpenTofu 进行云资源供应。设计模块化、可扩展的基础设施,具备适当的状态管理、远程后端以及 GitOps 驱动的自动化流水线。
场景: 构建一个安全、合规的多云着陆区。
实施:
成果:
场景: 构建一个生产就绪的 Kubernetes 平台。
实施:
成果:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
场景: 将手动配置的基础设施导入到 Terraform 中。
实施:
terraform importstate mv 进行资源重组成果:
terraform fmtterraform validatetflint 检查提供程序特定问题tfsec/checkov| 规模 | 策略 | 后端 |
|---|---|---|
| 个人 | 本地状态 | local(生产环境不推荐) |
| 小型团队 | 远程状态 + 锁定 | s3 + DynamoDB (AWS) / azurerm (Azure) |
| 企业 | 托管状态 + 运行 | Terraform Cloud / spacelift / env0 |
| GitOps | PR 驱动的运行 | Atlantis(自托管) |
你要构建什么?
│
├─ **根模块**("粘合剂")
│ ├─ `main.tf`:实例化子模块
│ ├─ `providers.tf`:提供程序配置
│ └─ `backend.tf`:状态配置
│
├─ **子模块**(可重用)
│ ├─ **资源模块**:包装单个资源(例如 `s3-secure-bucket`)
│ │ └─ 强制执行标签、加密、日志记录默认值。
│ │
│ └─ **基础设施模块**:逻辑分组(例如 `vpc-with-peering`)
│ └─ 组合 VPC、子网、路由表、NAT 网关。
│
└─ **组合**(Terragrunt/工作区)
├─ `prod/`
├─ `stage/`
└─ `dev/`
| 工具 | 方法 | 最佳适用场景 |
|---|---|---|
| Terraform | HCL(声明式) | 行业标准,庞大的生态系统。 |
| Pulumi | 通用编程语言(TS/Py) | 讨厌 HCL 的开发者,需要动态逻辑。 |
| Crossplane | K8s 自定义资源 | 控制平面,自助服务平台。 |
| CloudFormation | YAML/JSON | AWS 纯粹主义者(原生漂移检测)。 |
危险信号 → 升级给 security-engineer:
provider 代码块中硬编码 AWS 密钥terraform.tfstate)0.0.0.0/0 访问 SSH/RDP目标: 使用社区模块创建一个 3 层 VPC 网络。
步骤:
依赖定义(versions.tf)
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
实施(main.tf)
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.5.1"
name = "prod-vpc"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_nat_gateway = true
single_nat_gateway = false # 高可用性
enable_vpn_gateway = false
tags = {
Environment = "Production"
Terraform = "true"
}
}
输出(outputs.tf)
output "vpc_id" {
description = "VPC 的 ID"
value = module.vpc.vpc_id
}
目标: 将手动创建的 EC2 实例纳入 Terraform 控制。
步骤:
i-0123456789abcdef0resource "aws_instance" "legacy_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
# 填写其他已知细节...
}
terraform import aws_instance.legacy_server i-0123456789abcdef0
(或在 TF 1.5+ 中使用 import 代码块)
import {
to = aws_instance.legacy_server
id = "i-0123456789abcdef0"
}
terraform plan。表现形式:
main.tf 控制着 VPC、数据库、EKS 和 50 个微服务。terraform plan 需要 10 分钟。失败原因:
正确方法:
network、data、app-cluster。terraform_remote_state 数据源读取其他层的输出。表现形式:
vpc-prod.tf、vpc-dev.tf 文件。失败原因:
正确方法:
terraform workspace 和 var.environment 使用。prod.tfvars 与 dev.tfvars。.gitignore表现形式:
.terraform/ 目录(插件)。terraform.tfvars(密钥)。失败原因:
正确方法:
.gitignore:
.terraform/
*.tfstate
*.tfstate.backup
*.tfvars
.terraform.lock.hcl (这个要提交!)
代码质量:
terraform fmt -recursive。terraform validate。tflint 检查提供程序特定问题。terraform-docs 生成 README。安全:
encrypted = true。可靠性:
~> 5.0)。destroy 配置器(或为数据库启用保护)。create_before_destroy 冲突ignore_changes - 理解并管理变更sensitive 标志for_eachterraform fmt每周安装
66
仓库
GitHub 星标
42
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode54
claude-code49
codex48
gemini-cli48
cursor48
github-copilot42
Provides Infrastructure as Code expertise specializing in Terraform and OpenTofu for cloud provisioning. Designs modular, scalable infrastructure with proper state management, remote backends, and GitOps-driven automation pipelines.
Scenario: Building a secure, compliant multi-cloud landing zone.
Implementation:
Results:
Scenario: Building a production-ready Kubernetes platform.
Implementation:
Results:
Scenario: Importing manually provisioned infrastructure into Terraform.
Implementation:
Results:
| Scale | Strategy | Backend |
|---|---|---|
| Individual | Local State | local (Not recommended for prod) |
| Small Team | Remote State + Locking | s3 + DynamoDB (AWS) / azurerm (Azure) |
| Enterprise | Managed State + Runs | Terraform Cloud / spacelift / env0 |
| GitOps | PR-driven Runs | Atlantis (Self-hosted) |
What are you building?
│
├─ **Root Module** (The "Glue")
│ ├─ `main.tf`: Instantiates child modules
│ ├─ `providers.tf`: Provider config
│ └─ `backend.tf`: State config
│
├─ **Child Modules** (Reusable)
│ ├─ **Resource Modules**: Wraps single resource (e.g., `s3-secure-bucket`)
│ │ └─ Enforces tagging, encryption, logging defaults.
│ │
│ └─ **Infrastructure Modules**: Logical group (e.g., `vpc-with-peering`)
│ └─ Combines VPC, Subnets, Route Tables, NAT Gateways.
│
└─ **Composition** (Terragrunt/Workspaces)
├─ `prod/`
├─ `stage/`
└─ `dev/`
| Tool | Approach | Best For |
|---|---|---|
| Terraform | HCL (Declarative) | Industry standard, massive ecosystem. |
| Pulumi | General Purpose Lang (TS/Py) | Devs who hate HCL, dynamic logic. |
| Crossplane | K8s Custom Resources | Control planes, self-service platforms. |
| CloudFormation | YAML/JSON | AWS purists (drift detection is native). |
Red Flags → Escalate tosecurity-engineer:
provider blockterraform.tfstate)0.0.0.0/0 on SSH/RDPGoal: Create a 3-tier VPC network using the community module.
Steps:
Dependency Definition (versions.tf)
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
Implementation (main.tf)
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.5.1"
name = "prod-vpc"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_nat_gateway = true
single_nat_gateway = false # High Availability
enable_vpn_gateway = false
tags = {
Environment = "Production"
Terraform = "true"
}
}
Outputs (outputs.tf)
Goal: Bring a manually created EC2 instance under Terraform control.
Steps:
Identify Resource ID
i-0123456789abcdef0Write Terraform Code
resource "aws_instance" "legacy_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
# Fill in other known details...
}
Run Import
terraform import aws_instance.legacy_server i-0123456789abcdef0
(Or useimport block in TF 1.5+)
import {
to = aws_instance.legacy_server
id = "i-0123456789abcdef0"
}
4. Reconcile
* Run `terraform plan`.
* Update code to match the state until "No changes" is reported.
What it looks like:
main.tf controlling VPC, Database, EKS, and 50 Microservices.terraform plan takes 10 minutes.Why it fails:
Correct approach:
network, data, app-cluster.terraform_remote_state data source to read outputs from other layers.What it looks like:
vpc-prod.tf, vpc-dev.tf files with duplicated code.Why it fails:
Correct approach:
terraform workspace with var.environment.prod.tfvars vs dev.tfvars..gitignoreWhat it looks like:
.terraform/ directory (plugins).terraform.tfvars (secrets).Why it fails:
Correct approach:
Standard .gitignore for Terraform:
.terraform/
*.tfstate
*.tfstate.backup
*.tfvars
.terraform.lock.hcl (Commit this one!)
Code Quality:
terraform fmt -recursive.terraform validate.tflint for provider-specific issues.terraform-docs.Security:
encrypted = true on all storage (EBS, S3, RDS).Reliability:
~> 5.0).destroy provisioners tested (or protection enabled for DBs).Weekly Installs
66
Repository
GitHub Stars
42
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode54
claude-code49
codex48
gemini-cli48
cursor48
github-copilot42
output "vpc_id" {
description = "The ID of the VPC"
value = module.vpc.vpc_id
}