CertMaster

🏗️ Terraform Workflow & Best Practices

init, plan, apply, destroy, workspace, Terraform Cloud

Terraform Associate · TF-Associate · ⏱️ 20 min · ❓ 6 savol

🔄 Core Workflow

1. Write — HCL konfiguratsiya. 2. Init (`terraform init`) — provider plugin yuklab olish, backend init. 3. Plan (`terraform plan`) — nima o'zgarishini ko'rish. 4. Apply (`terraform apply`) — o'zgarish qo'llash. 5. Destroy (`terraform destroy`) — barcha resurslarni o'chirish.

🔧 Muhim Buyruqlar

`terraform fmt` — kod formatlash. `terraform validate` — konfiguratsiya tekshirish. `terraform show` — state ko'rish. `terraform output` — output qiymatlar. `terraform refresh` — state ni real holat bilan sync. `terraform taint` — resursni recreate uchun belgilash.

🌍 Workspaces

Bir config — bir nechta state. `terraform workspace new dev`. Har bir workspace alohida state file. Use case: dev/staging/prod uchun bir konfiguratsiya. Terraform Cloud — managed workspaces, remote run, VCS integration, policy as code (Sentinel).

🔐 Sensitive Data

Provider credential: env var, AWS profile, IAM role. HECH QACHON credential ni .tf faylga yozmang. Variable `sensitive = true` — output va log da yashiriladi. Secret management: HashiCorp Vault, AWS Secrets Manager.
💡 Asosiy nuqtalar
📋 Kod misoli
# Core workflow
terraform init           # Provider va backend init
terraform fmt            # Kodni formatlash
terraform validate       # Konfiguratsiya tekshirish
terraform plan           # O'zgarishlarni ko'rish
terraform plan -out=tfplan  # Plan saqlash
terraform apply tfplan   # Saqlangan planni apply
terraform destroy        # Barcha resurslarni o'chirish

# Workspace
terraform workspace list
terraform workspace new staging
terraform workspace select staging
terraform workspace show

# Useful flags
terraform apply -auto-approve  # Confirm so'ramasdan
terraform plan -var="region=eu-west-1"
terraform apply -target=aws_instance.web  # Faqat bitta resurs
🎯 Imtihon maslahatlari
⚠️ Ko'p adashadigan
🧠 Eslab qolish: "WIPA D" = Write, Init, Plan, Apply, Destroy — Terraform asosiy workflow 5 qadami

Terraform Workflow & Best Practices bo'yicha o'zingizni sinab ko'ring

Bepul interaktiv quiz, mock imtihon va to'liq darslar — CertMaster platformasida.

Bepul boshlash →