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

terraform-aws-modules

Skill này làm gì

Skill này giúp tạo và tổ chức code để quản lý hạ tầng Amazon Web Services (AWS) bằng công cụ Terraform. Nó tập trung xây dựng các thành phần code có thể tái sử dụng và đảm bảo việc quản lý trạng thái an toàn, hiệu quả.

Khi nào nên dùng

  • ✓Khi tạo các khối code có thể tái sử dụng cho AWS.
  • ✓Khi xem xét code Terraform để đảm bảo đúng thực hành tốt nhất.
  • ✓Khi lên kế hoạch lưu trữ thông tin trạng thái hạ tầng một cách an toàn.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/terraform-aws-modules/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-aws-modules/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

“Làm sao để tạo một module Terraform thiết lập mạng VPC trên AWS có thể tái sử dụng?”

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

Cách hoạt động

Skill hướng dẫn cách tổ chức code thành các tệp cụ thể (`variables.tf`, `outputs.tf`, `main.tf`) và dùng các thực hành khuyến nghị như khóa trạng thái từ xa cho nhóm và tự động định dạng code.

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.

You are an expert in Terraform for AWS specializing in reusable module design, state management, and production-grade HCL patterns.

Use this skill when

  • Creating reusable Terraform modules for AWS resources
  • Reviewing Terraform code for best practices and security
  • Designing remote state and workspace strategies
  • Migrating from CloudFormation or manual setup to Terraform

Do not use this skill when

  • The user needs AWS CDK or CloudFormation, not Terraform
  • The infrastructure is on a non-AWS provider

Instructions

  1. Structure modules with clear variables.tf, outputs.tf, main.tf, and versions.tf.
  2. Pin provider and module versions to avoid breaking changes.
  3. Use remote state (S3 + DynamoDB locking) for team environments.
  4. Apply terraform fmt and terraform validate before commits.
  5. Use for_each over count for resources that need stable identity.
  6. Tag all resources consistently using a default_tags block in the provider.

Examples

Example 1: Reusable VPC Module

# modules/vpc/variables.tf
variable "name" { type = string }
variable "cidr" { type = string, default = "10.0.0.0/16" }
variable "azs" { type = list(string) }

# modules/vpc/main.tf
resource "aws_vpc" "this" {
  cidr_block           = var.cidr
  enable_dns_support   = true
  enable_dns_hostnames = true
  tags = { Name = var.name }
}

# modules/vpc/outputs.tf
output "vpc_id" { value = aws_vpc.this.id }

Example 2: Remote State Backend

terraform {
  backend "s3" {
    bucket         = "my-tf-state"
    key            = "prod/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "tf-lock"
    encrypt        = true
  }
}

Best Practices

  • ✅ Do: Pin provider versions in versions.tf
  • ✅ Do: Use terraform plan output in PR reviews
  • ✅ Do: Store state in S3 with DynamoDB locking and encryption
  • ❌ Don't: Use count when resource identity matters — use for_each
  • ❌ Don't: Commit .tfstate files to version control

Troubleshooting

Problem: State lock not released after a failed apply Solution: Run terraform force-unlock <LOCK_ID> after confirming no other operations are running.

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

Terraform là gì?

Terraform là công cụ cho phép bạn mô tả và quản lý hạ tầng đám mây (như máy chủ, mạng, cơ sở dữ liệu) bằng các tệp code, thay vì nhấp qua giao diện.

Module Terraform là gì?

Module giống như một “gói” code Terraform thực hiện một nhiệm vụ cụ thể (ví dụ tạo mạng). Điều này cho phép bạn tái sử dụng cùng một code trong nhiều dự án.

Vì sao dùng remote state?

Remote state lưu thông tin về hạ tầng mà Terraform quản lý ở một vị trí từ xa (như AWS S3) có khóa (DynamoDB), ngăn nhiều người cùng thay đổi hạ tầng và gây lỗi.

Chi tiết

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

Terraform module creation for AWS — reusable modules, state management, and HCL best practices. Use when building or reviewing Terraform AWS infrastructure.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5959
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ự