Hands-on Lab No paid resource required

Lab 1: Account, CLI และ Budget Baseline

Lab นี้สร้างพื้นฐานก่อนทำ AWS Infrastructure จริง: Login ด้วย Identity ที่ไม่ใช่ Root, ตรวจ AWS CLI identity, ตั้ง AWS Budget และกำหนด Tagging convention สำหรับ Lab ถัดไป

Goal ยืนยันว่าทำงานด้วย identity ที่ถูกต้อง ตรวจ Console session และ AWS CLI caller identity ก่อนสร้าง resource ใด ๆ
Guardrail Budget รายเดือนพร้อม threshold ตั้ง 50%, 80%, 100% actual spend และ forecasted notification
Output Profile, Budget, Tag convention สิ่งเหล่านี้จะถูกใช้ซ้ำใน Phase ถัดไป ไม่ใช่แค่จบใน Lab นี้
Run order
  1. Login ด้วย identity ที่ไม่ใช่ root
  2. Configure AWS CLI profile แล้วตรวจ caller identity
  3. สร้าง Budget และ notification
  4. บันทึก tagging convention
  5. ตรวจ verification checklist ก่อน mark lab complete

Learning objectives

  • ตรวจว่าใช้งาน AWS Account ด้วย Identity ที่ปลอดภัยกว่า Root User
  • ตั้งค่า AWS CLI Profile และยืนยัน Account ด้วย aws sts get-caller-identity
  • สร้าง AWS Budget พร้อม Notification
  • กำหนด Tagging convention สำหรับ Resource ใน Lab ถัดไป

Prerequisites

  • AWS Account ที่เปิด MFA สำหรับ Root User แล้ว
  • IAM Identity Center หรือ IAM User สำหรับเรียน
  • AWS CLI v2 ติดตั้งบนเครื่อง
  • Email ที่รับ Budget notification ได้
Cost note: Lab นี้ไม่จำเป็นต้องสร้าง Compute หรือ Database แต่ Budget notification อาจมี delay หลังเกิดค่าใช้จ่ายจริง จึงต้องตรวจ Console และ cleanup resource จาก Lab อื่นเสมอ

Step 1: Login ด้วย Identity ที่ไม่ใช่ Root

  1. เข้า AWS Management Console
  2. Login ด้วย IAM Identity Center หรือ IAM User ที่เตรียมไว้
  3. ตรวจว่ามี MFA หรือ SSO session ที่เหมาะสม
  4. หลีกเลี่ยงการใช้ Root User ยกเว้นงาน Account-level ที่จำเป็น

Expected result: คุณอยู่ใน Console ด้วย Identity สำหรับงานประจำ ไม่ใช่ Root User

Step 2: Configure AWS CLI Profile

aws configure --profile learning

กรอกค่า Access Key, Secret Access Key, default Region และ output format ตาม Credential ที่เตรียมไว้

Default region name [None]: ap-southeast-1
Default output format [None]: json

Step 3: Verify caller identity

aws sts get-caller-identity --profile learning

ผลลัพธ์ควรมีโครงสร้างประมาณนี้:

{
  "UserId": "AIDASAMPLEUSERID",
  "Account": "123456789012",
  "Arn": "arn:aws:iam::123456789012:user/learning-user"
}

Step 4: Create AWS Budget

  1. เปิด Billing and Cost Management Console
  2. ไปที่ Budgets แล้วเลือก Create budget
  3. เลือก Cost budget
  4. ตั้ง Period เป็น Monthly
  5. กำหนด Amount เช่น 5 USD หรือค่าที่เหมาะกับการเรียน
  6. เพิ่ม Notification ที่ 50%, 80% และ 100% ของ actual spend
  7. เพิ่ม forecasted notification อย่างน้อยที่ 80%
  8. ใส่ Email ผู้รับแจ้งเตือนและยืนยัน Email ถ้าระบบร้องขอ

Step 5: Define Tagging convention

บันทึก convention นี้ไว้ใช้ใน Lab ถัดไป:

Environment = learning
Owner       = your-name
Project     = aws-infra-learning
ManagedBy   = manual-lab

Verification steps

Definition of done
  1. aws sts get-caller-identity --profile learning แสดง Account ID ถูกต้อง
  2. AWS Budgets แสดง Budget รายเดือนที่สร้างไว้
  3. Notification มี Email ถูกต้องและ Threshold ครบ
  4. คุณมี Tagging convention ที่จะใช้ซ้ำใน Phase ถัดไป

Troubleshooting

อาการแนวทางแก้
Unable to locate credentialsตรวจว่าใช้ --profile learning และเคยรัน aws configure --profile learning แล้ว
AccessDeniedตรวจ Permission ของ Identity หรือใช้ Identity ที่มีสิทธิ์ดู Billing/Budget
ไม่เห็น Billing Consoleตรวจว่ามีสิทธิ์ Billing และเปิด IAM access to billing information ตามรูปแบบ Account
ไม่ได้รับ Email แจ้งเตือนตรวจ Email, spam folder และสถานะ verification/subscription ถ้ามี SNS เกี่ยวข้อง

Cleanup procedures

Lab นี้ไม่สร้าง Compute, Database หรือ Network resource จึงไม่มี Resource ที่ต้องลบเพื่อหยุดค่าใช้จ่าย แต่ถ้าสร้าง Budget ทดลองหลายตัว ให้ลบ Budget ที่ไม่ใช้เพื่อไม่ให้เกิดความสับสน

Mini quiz

  1. ทำไมต้องตรวจ Account และ Arn ก่อนทำ Lab ที่สร้าง Resource?
  2. Budget actual notification กับ forecasted notification ต่างกันอย่างไร?
  3. Tag Environment และ Owner ช่วย Operation อย่างไร?