terraform-engineer
TerraformやOpenTofu、HCLを活用し、最新のステート管理でインフラをコードとして自動構築・運用するSkill。
📜 元の英語説明(参考)
Infrastructure as Code (IaC) expert using Terraform/OpenTofu, HCL, and modern state management.
🇯🇵 日本人クリエイター向け解説
TerraformやOpenTofu、HCLを活用し、最新のステート管理でインフラをコードとして自動構築・運用するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o terraform-engineer.zip https://jpskill.com/download/6748.zip && unzip -o terraform-engineer.zip && rm terraform-engineer.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/6748.zip -OutFile "$d\terraform-engineer.zip"; Expand-Archive "$d\terraform-engineer.zip" -DestinationPath $d -Force; ri "$d\terraform-engineer.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
terraform-engineer.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
terraform-engineerフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] terraform-engineer
Terraform エンジニア
目的
クラウドプロビジョニングのための Terraform および OpenTofu に特化した Infrastructure as Code の専門知識を提供します。適切なステート管理、リモートバックエンド、および GitOps 駆動の自動化パイプラインを備えた、モジュール式でスケーラブルなインフラストラクチャを設計します。
使用する場面
- 新しいクラウドインフラストラクチャ(VPC、EKS、RDS)のプロビジョニング
- モノリシックな Terraform コードを再利用可能なモジュールにリファクタリングする
- インフラストラクチャに「GitOps」を実装する(Atlantis/TFC)
- リモートステート、ロック、およびバックエンド構成を管理する
- カスタムプロバイダーまたは複雑な HCL ロジック(ループ、条件文)を記述する
- 既存の手動インフラストラクチャを Terraform に移行/インポートする
例
例 1: マルチクラウドランディングゾーン
シナリオ: 安全でコンプライアンスに準拠したマルチクラウドランディングゾーンを構築する。
実装:
- VPC、IAM、セキュリティグループ用の再利用可能なモジュールを作成しました。
- S3 バックエンドと DynamoDB ロックを使用したリモートステートを実装しました。
- 変数検証と事前条件を追加しました。
- コスト見積もりと予算アラートを実装しました。
- ステート管理のために Terraform Cloud をセットアップしました。
結果:
- インフラストラクチャのプロビジョニングが数週間から数時間に短縮されました。
- 環境間で 100% の一貫性が実現しました。
- セキュリティコンプライアンスが自動化されました。
- 最適化によりクラウドコストが 40% 削減されました。
例 2: EKS を使用した Kubernetes プラットフォーム
シナリオ: 本番環境に対応した Kubernetes プラットフォームを構築する。
実装:
- マネージドノードグループを持つ EKS モジュールを作成しました。
- RBAC とサービスアカウントを実装しました。
- ネットワークポリシーとセキュリティグループを追加しました。
- Vault 統合によるシークレット管理を構成しました。
- 監視と可観測性をセットアップしました。
結果:
- プラットフォームのデプロイが 30 分未満で完了しました。
- 設定ドリフトがゼロになりました。
- セキュリティ制御が組み込まれました。
- K8s バージョンの明確なアップグレードパスが確立されました。
例 3: レガシーインフラストラクチャの移行
シナリオ: 手動でプロビジョニングされたインフラストラクチャを Terraform にインポートする。
実装:
- 既存のリソースに
terraform importを使用しました。 - 対応する Terraform 構成を作成しました。
- リソースの再編成のために
state mvを実装しました。 - インポート中に変更がないことを確認しました。
- Terraform を信頼できる情報源として確立しました。
結果:
- 200 以上のリソースが Terraform に移行されました。
- インフラストラクチャがバージョン管理されるようになりました。
- Infrastructure as Code ワークフローが可能になりました。
- 監査とコンプライアンスが改善されました。
ベストプラクティス
ステート管理
- リモートバックエンド: 常にリモートステート(S3、GCS、Terraform Cloud)を使用してください。
- ステートロック: 同時変更を防止してください。
- ステート分離: 環境ごとにステートを分離してください。
- バックアップ: ステートのバージョン管理を有効にしてください。
モジュール開発
- 単一責任: 各モジュールは 1 つのことをうまく実行してください。
- バージョン固定: モジュールバージョンを固定してください。
- ドキュメント: 入力、出力、動作をドキュメント化してください。
- テスト: 公開する前にモジュールをテストしてください。
コード品質
- フォーマット:
terraform fmtを一貫して使用してください。 - 検証:
terraform validateを実行してください。 - リンティング: プロバイダー固有の問題には
tflintを使用してください。 - セキュリティスキャン:
tfsec/checkovを使用してください。
コラボレーション
- コードレビュー: すべての変更はマージ前にレビューしてください。
- ワークスペース戦略: 環境分離のためにワークスペースを使用してください。
- 変数管理: ハードコーディングではなく、変数ファイルを使用してください。
- 出力ドキュメント: 重要な出力をドキュメント化してください。
2. 意思決定フレームワーク
ステート管理戦略
| スケール | 戦略 | バックエンド |
|---|---|---|
| 個人 | ローカルステート | local (本番環境では非推奨) |
| 小規模チーム | リモートステート + ロック | s3 + DynamoDB (AWS) / azurerm (Azure) |
| エンタープライズ | マネージドステート + 実行 | Terraform Cloud / spacelift / env0 |
| GitOps | PR 駆動の実行 | Atlantis (セルフホスト) |
モジュールアーキテクチャ
何を作成していますか?
│
├─ **ルートモジュール** (The "Glue")
│ ├─ `main.tf`: 子モジュールをインスタンス化します
│ ├─ `providers.tf`: プロバイダー構成
│ └─ `backend.tf`: ステート構成
│
├─ **子モジュール** (再利用可能)
│ ├─ **リソースモジュール**: 単一のリソースをラップします (例: `s3-secure-bucket`)
│ │ └─ タグ付け、暗号化、ロギングのデフォルトを強制します。
│ │
│ └─ **インフラストラクチャモジュール**: 論理グループ (例: `vpc-with-peering`)
│ └─ VPC、サブネット、ルートテーブル、NAT ゲートウェイを組み合わせます。
│
└─ **コンポジション** (Terragrunt/Workspaces)
├─ `prod/`
├─ `stage/`
└─ `dev/`
Terraform vs. その他のツール
| ツール | アプローチ | 最適な用途 |
|---|---|---|
| Terraform | HCL (宣言型) | 業界標準、巨大なエコシステム。 |
| Pulumi | 汎用言語 (TS/Py) | HCL が嫌いな開発者、動的ロジック。 |
| Crossplane | K8s カスタムリソース | コントロールプレーン、セルフサービスプラットフォーム。 |
| CloudFormation | YAML/JSON | AWS 純粋主義者 (ドリフト検出はネイティブ)。 |
危険信号 → security-engineer にエスカレート:
providerブロックにハードコードされた AWS キー- Git に保存されたステートファイル (
terraform.tfstate) - SSH/RDP で
0.0.0.0/0を許可するセキュリティグループ - デフォルトでパブリックな S3 バケット
3. コアワークフロー
ワークフロー 1: 本番 AWS VPC (モジュール式)
目標: コミュニティモジュールを使用して 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" } } -
**出力 (`
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Terraform Engineer
Purpose
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.
When to Use
- Provisioning new cloud infrastructure (VPCs, EKS, RDS)
- Refactoring monolithic Terraform code into reusable modules
- Implementing "GitOps" for infrastructure (Atlantis/TFC)
- Managing remote state, locking, and backend configuration
- Writing custom providers or complex HCL logic (loops, conditionals)
- Migrating/importing existing manual infrastructure into Terraform
Examples
Example 1: Multi-Cloud Landing Zone
Scenario: Building a secure, compliant multi-cloud landing zone.
Implementation:
- Created reusable modules for VPC, IAM, security groups
- Implemented remote state with S3 backend and DynamoDB locking
- Added variable validation and preconditions
- Implemented cost estimation and budget alerts
- Set up Terraform Cloud for state management
Results:
- Infrastructure provisioning reduced from weeks to hours
- 100% consistency across environments
- Security compliance automated
- 40% reduction in cloud costs through optimization
Example 2: Kubernetes Platform with EKS
Scenario: Building a production-ready Kubernetes platform.
Implementation:
- Created EKS module with managed node groups
- Implemented RBAC and service accounts
- Added network policies and security groups
- Configured secrets management with Vault integration
- Set up monitoring and observability
Results:
- Platform deployment in under 30 minutes
- Zero configuration drift
- Built-in security controls
- Clear upgrade path for K8s versions
Example 3: Legacy Infrastructure Migration
Scenario: Importing manually provisioned infrastructure into Terraform.
Implementation:
- Used terraform import for existing resources
- Created corresponding Terraform configurations
- Implemented state mv for resource reorganization
- Verified no changes during import
- Established Terraform as source of truth
Results:
- 200+ resources migrated to Terraform
- Infrastructure now version controlled
- Enables infrastructure as code workflows
- Improved audit and compliance
Best Practices
State Management
- Remote Backend: Always use remote state (S3, GCS, Terraform Cloud)
- State Locking: Prevent concurrent modifications
- State Isolation: Separate state for environments
- Backup: Enable state versioning
Module Development
- Single Responsibility: Each module does one thing well
- Version Pinning: Lock module versions
- Documentation: Document inputs, outputs, behavior
- Testing: Test modules before publishing
Code Quality
- Formatting: Use terraform fmt consistently
- Validation: Run terraform validate
- Linting: Use tflint for provider-specific issues
- Security Scanning: Use tfsec/checkov
Collaboration
- Code Review: All changes reviewed before merge
- Workspace Strategy: Use workspaces for environment isolation
- Variable Management: Use variable files, not hardcoding
- Output Documentation: Document important outputs
2. Decision Framework
State Management Strategy
| 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) |
Module Architecture
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/`
Terraform vs. The World
| 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 to security-engineer:
- Hardcoded AWS keys in
providerblock - State files stored in git (
terraform.tfstate) - Security Groups allowing
0.0.0.0/0on SSH/RDP - S3 buckets public by default
3. Core Workflows
Workflow 1: Production AWS VPC (Modular)
Goal: 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)output "vpc_id" { description = "The ID of the VPC" value = module.vpc.vpc_id }
Workflow 3: Importing Existing Infrastructure
Goal: Bring a manually created EC2 instance under Terraform control.
Steps:
-
Identify Resource ID
- AWS Console → EC2 → Instance ID:
i-0123456789abcdef0
- AWS Console → EC2 → Instance ID:
-
Write 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 use
importblock in TF 1.5+)import { to = aws_instance.legacy_server id = "i-0123456789abcdef0" } -
Reconcile
- Run
terraform plan. - Update code to match the state until "No changes" is reported.
- Run
5. Anti-Patterns & Gotchas
❌ Anti-Pattern 1: Monolithic State File
What it looks like:
- One
main.tfcontrolling VPC, Database, EKS, and 50 Microservices. terraform plantakes 10 minutes.
Why it fails:
- Blast Radius: One error breaks everything.
- Performance: API rate limits (AWS Throttling).
- Locking: Dev A blocks Dev B.
Correct approach:
- Split State: Separate
network,data,app-cluster. - Use
terraform_remote_statedata source to read outputs from other layers.
❌ Anti-Pattern 2: Hardcoding Environments
What it looks like:
vpc-prod.tf,vpc-dev.tffiles with duplicated code.
Why it fails:
- Drift between environments.
- Double maintenance.
Correct approach:
- Workspaces: Use
terraform workspacewithvar.environment. - Tfvars:
prod.tfvarsvsdev.tfvars. - Modules: Reuse the same logic, pass different variables.
❌ Anti-Pattern 3: Ignoring .gitignore
What it looks like:
- Committing
.terraform/directory (plugins). - Committing
terraform.tfvars(secrets).
Why it fails:
- Repo bloat.
- Security leak.
Correct approach:
- Standard
.gitignorefor Terraform:.terraform/ *.tfstate *.tfstate.backup *.tfvars .terraform.lock.hcl (Commit this one!)
7. Quality Checklist
Code Quality:
- [ ] Formatting: Run
terraform fmt -recursive. - [ ] Validation: Run
terraform validate. - [ ] Linting: Run
tflintfor provider-specific issues. - [ ] Docs: Generate README using
terraform-docs.
Security:
- [ ] Secrets: No plain text secrets (Use KMS/Vault/Secrets Manager).
- [ ] Encryption:
encrypted = trueon all storage (EBS, S3, RDS). - [ ] Public Access: Locked down (S3 Block Public Access).
Reliability:
- [ ] State: Remote backend configured with locking.
- [ ] Versions: Provider and Terraform versions pinned (e.g.,
~> 5.0). - [ ] Cleanup:
destroyprovisioners tested (or protection enabled for DBs).
Anti-Patterns
State Management Anti-Patterns
- Local State: Using local state files - always use remote backends
- State Drift: Manual changes outside Terraform - use only Terraform for changes
- State Lock Contention: No state locking - implement proper locking
- State Corruption: Editing state files manually - never manually edit state
Module Anti-Patterns
- Monolithic Modules: Large, unwieldy modules - split into focused modules
- Hardcoded Values: Using values instead of variables - parameterize everything
- Module Version Chaos: No version pinning - pin module versions
- Deep Module Nesting: Over-nested module structures - keep module hierarchy flat
Resource Anti-Patterns
- Resource Spam: Many small resources instead of patterns - use resource grouping
- Lifecycle Lock: Resources that can't update - avoid create_before_destroy conflicts
- Ignored Changes: Overusing ignore_changes - understand and manage changes
- Sensitive Data Exposure: Plain text secrets in state - use sensitive flag
Code Organization Anti-Patterns
- Flat Structure: No directory organization - use modular structure
- Duplication: Repeated code blocks - use modules and for_each
- No Formatting: Unformatted HCL code - use terraform fmt
- Missing Documentation: undocumented modules - document all inputs/outputs