Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #5965

terraform-skill

Skill này làm gì

Công cụ này giúp bạn viết và tổ chức code để quản lý hạ tầng công nghệ (như máy chủ và cơ sở dữ liệu) một cách tự động và an toàn. Nó cung cấp các thực hành tốt nhất cho những công cụ như Terraform và OpenTofu.

Khi nào nên dùng

  • ✓Khi bạn tạo cấu hình mới để quản lý hạ tầng.
  • ✓Khi bạn thiết lập các bài test cho code hạ tầng.
  • ✓Khi bạn quyết định cách tổ chức code cho nhiều môi trường hoặc cho tích hợp liên tục.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/terraform-skill/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi muốn tạo một module Terraform mới để quản lý tài nguyên mạng, theo đúng thực hành tốt nhất về bảo mật và tổ chức.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích code hạ tầng của bạn, đề xuất cải tiến, kiểm tra bảo mật và giúp chọn cách tổ chức và kiểm thử code tốt nhất.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.
Câu hỏi thường gặp

“Hạ tầng như code” (infrastructure as code) là gì?

Đó là việc viết code để định nghĩa và quản lý hạ tầng CNTT, thay vì cấu hình thủ công. Cách này giúp quy trình lặp lại được, theo dõi được phiên bản và đáng tin cậy hơn.

Sự khác biệt giữa “count” và “for_each” trong Terraform là gì?

“count” dùng để tạo một số lượng cố định các tài nguyên giống nhau, còn “for_each” linh hoạt hơn, cho phép tạo tài nguyên dựa trên danh sách hoặc map, nên dễ bảo trì hơn khi thêm hoặc bớt các mục.

Vì sao cần kiểm thử hạ tầng?

Kiểm thử giúp đảm bảo hạ tầng hoạt động đúng như mong đợi, ngăn lỗi trên môi trường thật và xác minh cấu hình bảo mật đúng trước khi áp dụng.

Chi tiết

Mô tả gốc của tác giả

Terraform infrastructure as code best practices

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5965
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự