🎯 ภารกิจ — ตั้งบัญชีอย่างปลอดภัยและ deploy ครั้งแรก
ลงมือทำจริงในบัญชี AWS หรือ Cloudflare ของคุณ แล้วติ๊กรายการที่ทำได้ครบ ภารกิจที่มีป้าย “บังคับ” ต้องผ่านทุกข้อจึงจะเลื่อนระดับ อย่าลืมลบทรัพยากรที่สร้างเมื่อทำเสร็จ
ภารกิจบังคับ 0/3
บัญชี AWS ที่ปลอดภัยและไม่มีคีย์ถาวร
บังคับสิ่งที่ต้องทำ
ตั้งบัญชี AWS ตามบท 01 และ 03: root มี MFA, ผู้ใช้ IAM Identity Center + MFA, budget แจ้งเตือน และ CLI profile แบบ SSO จากนั้นรันสคริปต์ตรวจด้านล่าง แล้วบันทึกผลไว้ใน ~/cloud-ladder/README.md
คำสั่ง/โค้ดเริ่มต้น
ลองในAWS Console ↗#!/usr/bin/env bash # audit-aws.sh — ใช้: AWS_PROFILE=learn bash audit-aws.sh set -u aws sso login --profile "${AWS_PROFILE:-learn}" >/dev/null 2>&1 || true echo "== ตัวตน"; aws sts get-caller-identity --query Arn --output text echo "== root"; aws iam get-account-summary \ --query 'SummaryMap.[AccountMFAEnabled,AccountAccessKeysPresent]' --output text # ต้องเป็น 1 0 echo "== IAM users ที่มี access key" for u in $(aws iam list-users --query 'Users[].UserName' --output text); do aws iam list-access-keys --user-name "$u" --query 'AccessKeyMetadata[].AccessKeyId' --output text done ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) echo "== budgets"; aws budgets describe-budgets --account-id "$ACCOUNT_ID" \ --query 'Budgets[].[BudgetName,BudgetLimit.Amount]' --output text echo "== คีย์ในเครื่อง" test -f ~/.aws/credentials && echo "พบ ~/.aws/credentials" || echo "OK ไม่มี credentials file" env | grep -q '^AWS_SECRET_ACCESS_KEY=' && echo "พบคีย์ใน env" || echo "OK ไม่มีคีย์ใน env"เช็กลิสต์
บัญชี Cloudflare ที่ปลอดภัยพร้อม token จำกัดสิทธิ์
บังคับสิ่งที่ต้องทำ
เปิด 2FA เก็บ backup codes สร้าง API token สำหรับ Workers ที่จำกัดบัญชีและมี TTL ตรวจ token ด้วย curl และ wrangler login ในโปรเจกต์ ถ้ามีโดเมน ให้ย้าย NS มา Cloudflare จนสถานะ Active
คำสั่ง/โค้ดเริ่มต้น
ลองในCloudflare ↗# 1) ตรวจ token โดยไม่ทิ้งไว้ใน shell history read -rs CLOUDFLARE_API_TOKEN && export CLOUDFLARE_API_TOKEN curl -s https://api.cloudflare.com/client/v4/user/tokens/verify \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | python3 -m json.tool unset CLOUDFLARE_API_TOKEN # 2) wrangler ในโปรเจกต์ mkdir -p ~/cloud-ladder/hello-edge && cd ~/cloud-ladder/hello-edge npm init -y >/dev/null && npm i -D wrangler@latest npx wrangler login && npx wrangler whoami # 3) (ถ้ามีโดเมน) ตรวจ NS dig +short NS [โดเมนของคุณ] @1.1.1.1
เช็กลิสต์
เว็บเดียวกัน 2 ฝั่ง แล้วลบให้เกลี้ยง
บังคับสิ่งที่ต้องทำ
deploy เว็บจากบท 04 ทั้งแบบ S3 + CloudFront (OAC) และ Workers static assets ทดสอบด้วยสคริปต์ด้านล่าง บันทึกตารางเปรียบเทียบ (เวลา deploy, x-cache, 404, อ่านตรงจาก S3 ได้ไหม) แล้วลบทั้งหมดตามบท 05 และรันการตรวจซ้ำให้ผลว่าง
คำสั่ง/โค้ดเริ่มต้น
ลองในAWS Console ↗Cloudflare ↗#!/usr/bin/env bash # compare.sh — ใช้: bash compare.sh d111111abcdef8.cloudfront.net hello-edge.[subdomain].workers.dev [bucket] [region] CF=$1; WK=$2; BUCKET=$3; REGION=${4:-ap-southeast-1} for host in "$CF" "$WK"; do echo "== $host" curl -sI "https://$host/" | grep -iE '^(HTTP|server|x-cache|age)' curl -so /dev/null -w "404 test: %{http_code} | ttfb %{time_starttransfer}s\n" "https://$host/nope" done echo "== อ่านตรงจาก S3 (ต้องได้ 403)" curl -so /dev/null -w "%{http_code}\n" "https://$BUCKET.s3.$REGION.amazonaws.com/index.html"เช็กลิสต์
ให้ AI ช่วยรีวิว lab ก่อนรันจริง
โบนัสสิ่งที่ต้องทำ
นำชุดคำสั่ง clean-up ของคุณ (หรือสคริปต์ที่เขียนเอง) ให้ Claude หรือ Gemini รีวิวหาความเสี่ยง แล้วปรับสคริปต์ให้ปลอดภัยขึ้น เช่น ตรวจบัญชีก่อนลบ ถามยืนยัน และพิมพ์สิ่งที่จะลบก่อนลบจริง
คำสั่ง/โค้ดเริ่มต้น
ลองในAWS Console ↗Cloudflare ↗ฉันเป็นมือใหม่ด้าน AWS/Cloudflare นี่คือสคริปต์ที่ใช้ลบของหลังทำ lab: [วางสคริปต์ — ลบค่า Account ID, token, อีเมลจริงออกก่อนวาง] ช่วยรีวิวเป็นตาราง: บรรทัด | ความเสี่ยง | แก้อย่างไร ตรวจโดยเฉพาะ: ลบผิดบัญชี/ผิด region ได้ไหม, ลำดับการลบถูกไหม, มีอะไรที่เสียเงินแล้วสคริปต์ไม่ได้ลบ แล้วเขียนเวอร์ชันใหม่ที่ (1) แสดง aws sts get-caller-identity และถามยืนยันก่อน (2) dry-run พิมพ์สิ่งที่จะลบ ห้ามแนะนำให้สร้าง access key ถาวร
เช็กลิสต์