本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)48k · #5965

terraform-skill

できること

このツールは、サーバーやデータベースなどのIT基盤を、自動的かつ安全に管理するためのコードを書いて整理するのに役立ちます。Terraform や OpenTofu などのツールを使うときのベストプラクティスを提供します。

使う場面

  • ✓IT基盤を管理するための新しい構成を作成するとき。
  • ✓基盤のコードに対するテストを設定するとき。
  • ✓複数の環境向けや継続的インテグレーション(CI)向けに、コードの構成方法を決めるとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/terraform-skill/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/terraform-skill/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“ネットワークリソースを管理する新しい Terraform モジュールを作りたいです。セキュリティと整理の両面でベストプラクティスに沿った形にしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

基盤のコードを分析して改善案を提示し、セキュリティをチェックします。また、コードを整理する方法やテストの方法として最適なアプローチを選ぶのを手伝います。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Terraform Skill for Claude

Comprehensive Terraform and OpenTofu guidance covering testing, modules, CI/CD, and production patterns. Based on terraform-best-practices.com and enterprise experience.

Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use This Skill

Activate this skill when:

  • Creating new Terraform or OpenTofu configurations or modules
  • Setting up testing infrastructure for IaC code
  • Deciding between testing approaches (validate, plan, frameworks)
  • Structuring multi-environment deployments
  • Implementing CI/CD for infrastructure-as-code
  • Reviewing or refactoring existing Terraform/OpenTofu projects
  • Choosing between module patterns or state management approaches

Don't use this skill for:

  • Basic Terraform/OpenTofu syntax questions (Claude knows this)
  • Provider-specific API reference (link to docs instead)
  • Cloud platform questions unrelated to Terraform/OpenTofu

Count vs For_Each: When to Use Each

Quick Decision Guide

Scenario Use Why
Boolean condition (create or don't) count = condition ? 1 : 0 Simple on/off toggle
Simple numeric replication count = 3 Fixed number of identical resources
Items may be reordered/removed for_each = toset(list) Stable resource addresses
Reference by key for_each = map Named access to resources
Multiple named resources for_each Better maintainability

Common Patterns

Boolean conditions:

# ✅ GOOD - Boolean condition
resource "aws_nat_gateway" "this" {
  count = var.create_nat_gateway ? 1 : 0
  # ...
}

Stable addressing with for_each:

# ✅ GOOD - Removing "us-east-1b" only affects that subnet
resource "aws_subnet" "private" {
  for_each = toset(var.availability_zones)

  availability_zone = each.key
  # ...
}

# ❌ BAD - Removing middle AZ recreates all subsequent subnets
resource "aws_subnet" "private" {
  count = length(var.availability_zones)

  availability_zone = var.availability_zones[count.index]
  # ...
}

For migration guides and detailed examples, see: Code Patterns: Count vs For_Each

Security & Compliance

Essential Security Checks

# Static security scanning
trivy config .
checkov -d .

Common Issues to Avoid

❌ Don't:

  • Store secrets in variables
  • Use default VPC
  • Skip encryption
  • Open security groups to 0.0.0.0/0

✅ Do:

  • Use AWS Secrets Manager / Parameter Store
  • Create dedicated VPCs
  • Enable encryption at rest
  • Use least-privilege security groups

For detailed security guidance, see:

  • Security & Compliance Guide - Trivy/Checkov integration, secrets management, state file security, compliance testing

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
よくある質問

「Infrastructure as Code(IaC)」とは何ですか?

IT基盤を手作業で設定するのではなく、コードでその構成を定義して管理する方法です。これにより、同じ手順を何度でも再現でき、変更履歴を管理しやすくなり、信頼性も高まります。

Terraform の「count」と「for_each」の違いは何ですか?

「count」は同じリソースを決まった数だけ作成するときに使います。「for_each」はリストやマップをもとにリソースを作成できるため柔軟性が高く、項目を追加・削除するときの管理がしやすくなります。

なぜIT基盤のテストが大切なのですか?

テストによって、基盤が想定どおりに動くことを確認でき、本番環境でのエラーを防げます。また、適用前にセキュリティ設定が正しいかも確認できます。

詳細

作者による元の説明

Terraform infrastructure as code best practices

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#5965
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル