ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
`terraform validate` က syntax error (typo, wrong argument name) ကို cloud API ခေါ်စရာ မလိုဘဲ local မှာပဲ စစ်ပေးပါတယ် — commit မလုပ်ခင် quick sanity check အနေနဲ့ အသုံးဝင်ပါတယ်။ `terraform fmt` က code style (indentation, spacing) ကို standard format အတိုင်း auto-fix ပေးပါတယ် — team member အားလုံးက code style တူညီအောင် ကူညီပေးပါတယ်။ CI/CD pipeline (GitHub Actions) ထဲမှာ Pull Request တင်တိုင်း `terraform plan` ကို auto-run ပြီး comment အနေနဲ့ ပြပေးအောင် setup လုပ်လေ့ရှိပါတယ် — team member က code review လုပ်တဲ့အခါ 'ဘာတွေ ပြောင်းမလဲ' ကို PR ပေါ်မှာပဲ တွေ့နိုင်ပါတယ်, `apply` ကတော့ merge ပြီးမှ (ဒါမှမဟုတ် manual approval ရမှ) run ပါလေ့ရှိပါတယ်.
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
GitHub Actions workflow file ထဲမှာ `terraform fmt -check` (format မမှန်ရင် fail), `terraform validate` (syntax error ရှိရင် fail), `terraform plan` (change preview) ကို step အလိုက် run ထားရင် — developer က config ကို push လိုက်တိုင်း automatic check ဖြစ်သွားပြီး, human error ကို early ရှာတွေ့နိုင်ပါတယ်.
အတူတူ ကြည့်မယ်
# .github/workflows/terraform.yml (simplified)
name: Terraform
on: [pull_request]
jobs:
plan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- run: terraform init
- run: terraform fmt -check
- run: terraform validate
- run: terraform plan$ terraform fmt -check
$ terraform validate
Success! The configuration is valid.
$ terraform plan
Plan: 2 to add, 0 to change, 0 to destroy.၅ မိနစ် စမ်းကြည့်
Local config folder တစ်ခုမှာ `terraform fmt -check` နဲ့ `terraform validate` command နှစ်ခုလုံးကို run ကြည့်ပါ — code style တမင် ရှုပ်ထွေးအောင် ရေးထားပြီး `fmt` က ဘယ်လို auto-fix ပေးလဲ ကြည့်ကြည့်ပါ။
သတိလေးတစ်ချက်
CI/CD pipeline ရဲ့ credential (AWS access key) ကို repository secret အနေနဲ့ properly သိမ်းထားပါ — workflow file ထဲ hardcode လုံးဝ မရေးပါနှင့်။