ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
HCL syntax က JSON/YAML ထက် ဖတ်ရလွယ်အောင် ဒီဇိုင်းလုပ်ထားပါတယ် — `block_type "label" { argument = value }` ဆိုတဲ့ pattern ကို အထပ်ထပ် တွေ့ရပါလိမ့်မယ်။ Block type (resource, provider, variable, output) တွေက Terraform ရဲ့ 'keyword' တွေပါ။ Argument က `key = value` pattern ပါ — value က string, number, boolean, list, map ဖြစ်နိုင်ပါတယ်။ Expression ကတော့ `${...}` (modern HCL မှာ ချန်ထားလို့ရတဲ့) reference syntax ဖြင့် value တစ်ခုချင်းစီကို တခြား resource ရဲ့ output နဲ့ ချိတ်ဆက်ခြင်း ပါ။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
`resource "local_file" "greeting" { filename = "hello.txt"; content = "Hello, Terraform!" }` ဆိုတဲ့ code က 'local_file type ရဲ့ resource တစ်ခု၊ ကိုယ့် config ထဲမှာ greeting လို့ ခေါ်မယ်၊ filename နဲ့ content argument ၂ ခုပါ' လို့ ဖတ်ရပါတယ်။ Comment ကို `#` (ဒါမှမဟုတ် `//`) နဲ့ ရေးလို့ရပြီး, multi-line string ကို heredoc syntax (`<<EOF ... EOF`) နဲ့ ရေးလို့ရပါတယ်.
အတူတူ ကြည့်မယ်
# This is a comment
resource "local_file" "greeting" {
filename = "hello.txt"
content = "Hello, Terraform!"
}
variable "environment" {
type = string
default = "dev"
}
locals {
tags = {
project = "tutorial"
owner = "student"
}
}HCL block/argument/expression syntax ကို ဖတ်ရှင်းနိုင်မည်။၅ မိနစ် စမ်းကြည့်
အထက်က HCL code ကို ဖတ်ပြီး, block type ၃ ခု (resource, variable, locals) ရဲ့ label/argument ဘာတွေလဲ ကိုယ်တိုင် ခွဲခြားရေးကြည့်ပါ။
သတိလေးတစ်ချက်
HCL file extension က `.tf` ပါ — folder ထဲက `.tf` file အားလုံးကို Terraform က တစ်ခါတည်း (တစ်ဖိုင်ချင်းစီ သီးခြား run တာ မဟုတ်ဘဲ) ပေါင်းပြီး load ပါတယ်။