Chuyển tới nội dung chính

Terraform

Terraform là công cụ Infrastructure as Code (IaC) phổ biến nhất hiện nay, cho phép định nghĩa, provision và quản lý hạ tầng cloud bằng code thay vì click tay trên console.

Tại sao cần Terraform?

Vấn đề với manualGiải pháp với Terraform
Cấu hình khác nhau giữa staging và productionCode giống nhau, chỉ khác variables
Không biết ai đã thay đổi gìMọi thay đổi qua Git, có history
Tạo lại môi trường mất hàng giờterraform apply tự động hoàn toàn
Dễ quên bước nào đó khi setupCode = documentation

Terraform hoạt động như thế nào?

[Bạn viết .tf files] → terraform plan → [Xem thay đổi] → terraform apply → [Hạ tầng được tạo]

Terraform gọi Cloud APIs
(AWS, GCP, Azure, ...)

Các chủ đề trong series

BàiNội dung
Core ConceptsProvider, Resource, State, Plan/Apply — 5 khái niệm cốt lõi
HCL SyntaxCú pháp ngôn ngữ HCL: blocks, expressions, functions
Variables & OutputsInput variables, locals, outputs, tfvars
ProvidersCấu hình providers: AWS, versioning, multiple providers
Resources & Data SourcesTạo resources, data sources, dependencies, lifecycle
ModulesTái sử dụng code với modules, Terraform Registry
State ManagementState file, remote state trên S3, state locking
WorkspacesQuản lý nhiều environments (dev/staging/prod)
CI/CD IntegrationChạy Terraform trong GitHub Actions pipeline

Nội dung đang được chuẩn bị theo thứ tự. Theo dõi để cập nhật mới nhất!