Hands-on LabMay create billable resources

Lab 8: Security Baseline

Lab นี้สร้าง security baseline สำหรับ workload ตัวอย่าง: จัดการ database credential, ใช้ KMS กับ storage, เพิ่ม WAF rule และเปิด threat detection/recommendations

Learning objectives

  • เก็บ Database Credential ใน Secrets Manager
  • ใช้ KMS เข้ารหัส S3 และ EBS
  • สร้าง AWS WAF Rule พื้นฐาน
  • เปิด GuardDuty และตรวจ Finding ตัวอย่าง
  • เปิด Security Hub และอ่าน recommendations

Prerequisites

  • มี AWS Account สำหรับ Lab และตั้ง Budget แล้ว
  • มี S3 bucket หรือ test bucket ที่สร้างใหม่ได้
  • มี EC2/EBS test resource หรือเข้าใจว่าจะสร้างแล้วลบหลังจบ Lab
  • มี ALB หรือ CloudFront distribution ถ้าจะ associate WAF Web ACL
  • มี permission สำหรับ KMS, Secrets Manager, WAF, GuardDuty และ Security Hub

Step 1: Store database credential in Secrets Manager

aws secretsmanager create-secret \
  --name learning/db/credential \
  --description "Learning database credential" \
  --secret-string '{"username":"learning_user","password":"ChangeMe-UseStrongPassword"}'

ให้ application role อ่าน secret ด้วย permission เฉพาะ secret ARN ที่ต้องใช้เท่านั้น

Step 2: Use KMS with S3

  1. Create Customer Managed Key หรือใช้ key ที่องค์กรกำหนด
  2. เปิด default encryption ของ S3 bucket เป็น SSE-KMS
  3. Upload object และตรวจ properties ว่า encryption เป็น SSE-KMS

Step 3: Use encryption with EBS

  1. สร้าง EBS volume test พร้อม encryption enabled
  2. เลือก KMS key ที่เหมาะสม
  3. Attach กับ test EC2 เฉพาะถ้าต้องทดสอบ mount จริง

Step 4: Create a basic WAF rule

  1. Create Web ACL สำหรับ Regional resource หรือ CloudFront ตาม workload
  2. Add AWS Managed Rules เช่น Core rule set
  3. Add rate-based rule สำหรับ path สำคัญ เช่น login endpoint
  4. เริ่มจาก Count mode แล้วดู sampled requests ก่อนเปลี่ยนเป็น Block

Step 5: Enable GuardDuty

  1. เปิด GuardDuty ใน Region ที่ใช้ Lab
  2. ดูหน้า Findings และลอง Generate sample findings ถ้าใช้ Console
  3. อ่าน finding type, severity, affected resource และ recommended action

Step 6: Enable Security Hub

  1. เปิด Security Hub
  2. Enable AWS Foundational Security Best Practices standard
  3. ดู failed controls และจด remediation ที่เกี่ยวกับ S3, IAM, CloudTrail หรือ Security Groups

Expected results

  • มี secret สำหรับ database credential พร้อม ARN
  • S3 bucket ใช้ SSE-KMS
  • EBS test volume เปิด encryption
  • WAF Web ACL มี managed rule และ/หรือ rate-based rule
  • GuardDuty แสดง findings หรือ sample findings ได้
  • Security Hub แสดง recommendations/controls ให้ตรวจต่อได้

Verification steps

aws secretsmanager describe-secret --secret-id learning/db/credential
aws s3api get-bucket-encryption --bucket YOUR_BUCKET_NAME
aws guardduty list-detectors
aws securityhub get-enabled-standards

Troubleshooting

อาการแนวทางแก้
Application อ่าน secret ไม่ได้ตรวจ IAM role, secret ARN, KMS permission และ Region
S3 upload fail หลังใช้ SSE-KMSตรวจว่า principal มี kms:GenerateDataKey และ kms:Decrypt ตาม use case
WAF block traffic ปกติกลับไป Count mode และดู sampled requests ก่อนปรับ rule
Security Hub ไม่มีผลทันทีรอ evaluation cycle และตรวจว่า standard ถูก enabled แล้ว

Cleanup procedures

  1. Delete test secret ถ้าไม่ใช้ต่อ
  2. Delete test EBS volume
  3. Detach/Delete WAF Web ACL หรือ rule ที่สร้างเพื่อ Lab
  4. Disable GuardDuty/Security Hub เฉพาะ account Lab ถ้าไม่ต้องการเสียค่าใช้จ่ายต่อ
  5. Schedule deletion ของ KMS key เฉพาะ key ที่สร้างเพื่อ Lab และไม่มี data สำคัญผูกอยู่

Mini quiz

  1. ทำไมต้องระวังการลบ KMS key?
  2. WAF Count mode ช่วยลดความเสี่ยงอย่างไร?
  3. Security Hub recommendation ควรถูกนำไปใช้ใน workflow ใด?