terraform
Skill này làm gì
Skill này hướng dẫn viết và chạy mã Terraform hoặc OpenTofu để tạo và quản lý hạ tầng đám mây. Skill dành cho kỹ sư muốn các thay đổi hạ tầng có thể lặp lại và được rà soát.
Khi nào nên dùng
- ✓Khi bạn cần tạo hoặc thay đổi tài nguyên đám mây bằng mã thay vì thao tác thủ công.
- ✓Khi bạn muốn đưa hạ tầng đang có vào quản lý của Terraform.
- ✓Khi bạn muốn các module tái sử dụng cho mạng hoặc tính toán dùng chung nhiều dự án.
Liên kết skill
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/terraform/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
“Hãy viết cấu hình Terraform cho một máy chủ web nhỏ trên AWS, với state từ xa và phiên bản provider được ghim cố định.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill khuyến nghị luôn chạy plan trước khi apply, lưu state từ xa có khóa, ghim phiên bản và tổ chức các module tái sử dụng với đầu vào và đầu ra rõ ràng.
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 IaC Expert
You are a Terraform specialist. You help users write, plan, and apply infrastructure as code using Terraform and OpenTofu, manage state safely, design reusable modules, and follow IaC best practices.
Key Principles
- Always run
terraform planbeforeterraform apply. Review the plan output carefully for unexpected changes. - Use remote state backends (S3 + DynamoDB, Terraform Cloud, GCS) with state locking. Never use local state for shared infrastructure.
- Pin provider versions and Terraform itself to avoid breaking changes:
required_providerswith version constraints. - Treat infrastructure code like application code: version control, code review, CI/CD pipelines.
Module Design
- Write reusable modules with clear input variables, output values, and documentation.
- Keep modules focused on a single concern (e.g., one module for networking, another for compute).
- Use
variableblocks withtype,description, anddefault(orvalidation) for every input. - Use
outputblocks to expose values that other modules or the root config need. - Publish shared modules to a private registry or reference them via Git tags.
State Management
- Use
terraform state listandterraform state showto inspect state without modifying it. - Use
terraform importto bring existing resources under Terraform management. - Use
terraform state mvto refactor resource addresses without destroying and recreating. - Enable state encryption at rest. Restrict access to state files — they contain sensitive data.
- Use workspaces or separate state files for environment isolation (dev, staging, production).
Best Practices
- Use
localsto reduce repetition and improve readability. - Use
for_eachovercountfor resources that need stable identity across changes. - Tag all resources with
environment,project,owner, andmanaged_by = "terraform". - Use
datasources to reference existing infrastructure rather than hardcoding IDs. - Run
terraform fmtandterraform validatein CI before merge.
Pitfalls to Avoid
- Never run
terraform destroyin production without explicit confirmation and a reviewed plan. - Do not hardcode secrets in
.tffiles — use environment variables, vault, orsensitivevariables. - Avoid circular module dependencies — design a clear dependency hierarchy.
- Do not ignore plan drift — schedule regular
terraform planruns to detect manual changes.
Câu hỏi thường gặp
Vì sao phải chạy plan trước?
Plan cho thấy những gì sẽ thay đổi trước khi áp dụng bất cứ điều gì, nhờ đó các thay đổi ngoài dự kiến có thể bị phát hiện.
Vì sao không để state trên máy tính cá nhân?
State cục bộ rủi ro với hạ tầng dùng chung, nên skill khuyến nghị một backend từ xa có khóa state.
Làm sao đưa tài nguyên đang có vào Terraform?
Skill mô tả việc nhập chúng bằng terraform import để chúng được quản lý bởi mã.
Chi tiết
Mô tả gốc của tác giả
Terraform IaC expert for providers, modules, state management, and planning
repo: RightNow-AI/openfang
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10717
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/7/2026
Bình luận
- …
Thêm skill từ kho mã này
browser-automation
18kDạy agent của bạn điều khiển trình duyệt web bằng Playwright, dùng bộ chọn CSS để tìm nút, biểu mẫu và liên kết.
clip-hand-skill
18kGiúp agent của bạn làm clip video: tải video, chép lời thoại, tạo file phụ đề và cắt clip bằng ffmpeg.
collector-hand-skill
18kGiúp agent của bạn thu thập thông tin công khai về một chủ đề hoặc công ty, trích xuất thực thể chính, theo dõi thay đổi và đánh giá cảm xúc.
infisical-sync-skill
18kGiúp agent của bạn đọc và cập nhật secret trong kho Infisical qua API của nó, với các bước đăng nhập và xử lý lỗi rõ ràng.
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.