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.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
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
Độ 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
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
openclaw-update
394kGiúp agent của bạn cập nhật OpenClaw Gateway đang có, chọn cách cập nhật phù hợp với cách cài đặt và giữ phiên làm việc của bạn hoạt động.
diagnose-gateway
394kGiúp agent của bạn tìm hiểu vì sao OpenClaw Gateway bị lỗi bằng cách kiểm tra cài đặt, kênh và cổng mà không thay đổi gì.
crabbox-apps
394kGiúp agent của bạn mở và chạy một app trên máy đám mây tạm thời, rồi hiển thị giao diện của nó trong thanh bên của chat.