Thuta Learning
ရှာဖွေရန်
ExercisesDevOpsintermediate

လက်တွေ့ လေ့ကျင့်ခန်း အစုံ ၁

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • လက်တွေ့ လေ့ကျင့်ခန်း အစုံ ၁ ကို ကြောက်စရာမလိုအောင် နားလည်မယ်
  • ကိုယ်တိုင် terraform command/HCL code ကို run ကြည့်တတ်မယ်
  • Real project ထဲမှာ ဒီ concept ကို ချက်ချင်း အသုံးချတတ်မယ်

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

ဒီ round က learn ခဲ့ပြီးသား Basic/Intermediate concept တွေကို လက်တွေ့ ပြန်စမ်းကြည့်ဖို့ round ပါ — Resource vs Variable vs Output ကို ခွဲသိခြင်း, HCL config ထဲက error ကို ရှာဖွေခြင်း, `terraform` command ကို မှန်ကန်စွာ ရေးတတ်ခြင်းကိုပဲ ကိုယ်တိုင် လက်တွေ့ လုပ်ကြည့်ရမှာပါ။ Task တစ်ခုချင်းစီက ၅ မိနစ်ထက် မကြာသင့်ပါဘူး။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Task 1: 'Resource', 'Variable', 'Output' သုံးလုံးရဲ့ တာဝန် ကွာခြားချက်ကို ဝါကျတစ်ကြောင်းစီနဲ့ ရှင်းပြပါ။ Task 2: `resource "aws_instance" "web" { instance_type = var.instance_type }` လို့ ရေးထားပေမယ့် `variable "instance_type"` block ကို config file ထဲမှာ လုံးဝ define မလုပ်ထားရင် ဘာ error ဖြစ်မလဲ ခန့်မှန်းပြီး ရေးပါ။ Task 3: State file ဆိုတာ ဘာလို့ အရေးကြီးလဲ, local state ရဲ့ risk ဘာတွေလဲ ဥပမာနဲ့တကွ ရေးပါ။ Task 4: `terraform plan` run လိုက်ရင် unexpected change (drift) တွေ့ရတယ်ဆိုရင် ဘယ် command ၂ ခုနဲ့ investigate စမလဲ ရေးပါ။

အတူတူ ကြည့်မယ်

text
# Task 2 - undefined variable
resource "aws_instance" "web" {
  instance_type = var.instance_type   # ERROR!
}
# No `variable "instance_type" { ... }` block exists anywhere.

Result: Terraform will error at `terraform plan` time with
something like: "Reference to undeclared input variable"

# Task 4 - investigating drift
terraform plan                        # shows what changed vs config
terraform state show <resource>       # inspect the current tracked state
You should see
Resource/Variable/Output ကွာခြားချက်၊ undefined variable error ရှာဖွေခြင်း၊ drift investigate command များ ရရှိလာမည်။

၅ မိနစ် စမ်းကြည့်

ကိုယ်ပိုင် config တစ်ခု ရေးပြီး တမင် undefined variable reference bug ထည့်ကြည့်ပါ — `terraform plan` ပြီးရင် ဘာဖြစ်လဲ ကိုယ်တိုင် သက်သေပြကြည့်ပါ။

သတိလေးတစ်ချက်

ဒီ round မှာ cloud account setup လုပ်ဖို့ မလိုပါဘူး — concept/debugging logic ကိုပဲ အဓိကထား practice လုပ်ခြင်းပါ။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Resource/Variable/Output ကို 'အားလုံးတူတူပဲ' လို့ ရှုပ်ထွေးနေခြင်း
  • Error message ကို terminal output ကနေ ဖတ်ရှုချသွားပြီး error ဘယ် line မှာလဲ မကြည့်ခြင်း

အခု ကိုယ်တိုင် စမ်းကြည့်

ကိုယ်ပိုင် config တစ်ခု ရေးပြီး တမင် undefined variable reference bug ထည့်ကြည့်ပါ — `terraform plan` ပြီးရင် ဘာဖြစ်လဲ ကိုယ်တိုင် သက်သေပြကြည့်ပါ။

You'll know it worked when: Resource/Variable/Output ကွာခြားချက်၊ undefined variable error ရှာဖွေခြင်း၊ drift investigate command များ ရရှိလာမည်။

လက်တွေ့ လေ့ကျင့်ခန်း အစုံ ၁ | Thuta Learning