ข้ามไปยังเนื้อหา

Module 8 — Automation

🧠 ภาพจำก่อนอ่าน: 📜 Code → ⚙️ Deploy → 🔎 Drift → ✅ Verify
🎨 Visual Guide ของวิชานี้ — ภาพช่วยจำ ไม่แทนคำอธิบายและคำสั่งจริง

flowchart LR
    CODE[Template / Code] --> CFN[CloudFormation]
    CODE --> CDK[AWS CDK]
    CDK --> CFN
    CFN --> STACK[Stack]
    STACK --> R1[Compute]
    STACK --> R2[Network]
    STACK --> R3[Database]
    SSM[Systems Manager] --> R1

Module 8 visual diagram

Diagram นี้เป็นภาพสรุปเพื่อช่วยทำความเข้าใจโครงสร้างของบท/แล็บ โดยยึดแนวคิดจากคู่มือต้นฉบับ Mobile reader copy combined from Part 1 + Part 2. Full source screenshots remain in Google Drive master.

Source: Architecting on AWS 7.12.4 (EN) — Student Guide
PDF pages: 395–406
Scope: Business request → Infrastructure as Code (IaC) → AWS CloudFormation → Templates → Stacks → Layered architecture


Module 8 เริ่มจาก business request ของ Chief Technology Officer ที่ต้องการรู้ว่า

  • จะทำให้การ build cloud infrastructure ง่ายขึ้นได้อย่างไร
  • จะ deploy, maintain และ scale application ใน cloud ได้อย่างไร

ช่วง Part 1 ตอบคำถามแรกด้วยแนวคิด Infrastructure as Code (IaC) และ AWS CloudFormation


Student Guide อธิบาย IaC ว่าเป็นการใช้ code เพื่อ define, deploy, configure, update และ remove infrastructure

🖼️ Source figure — Student Guide p.400; full screenshot is kept in the Google Drive master copy.

แนวคิดหลักคือแทนที่จะสร้าง resource ด้วยการคลิก console ทีละอย่าง เราเขียน template ที่อธิบาย resource และ configuration ที่ต้องการ แล้วใช้ automation สร้าง infrastructure จาก template นั้น

flowchart LR
    T[Architecture template]
    I[IaC solution]
    R[AWS resources]
    T --> I --> R

ตาม Student Guide:

  • replicate, redeploy และ repurpose infrastructure
  • ทำ version control กับ infrastructure/application definition
  • detect drift
  • roll back configuration ไป state ก่อนหน้า

template สามารถเขียนเป็น JSON หรือ YAML และใช้ define application stack ทั้งชุด รวมถึง resource และ parameter ที่ต้องใช้

Student Guide เน้นประโยชน์หลายด้าน

infrastructure ถูกสร้างแบบ programmatically จึงเร็วกว่า manual deployment และลด human error

template เดิมสามารถ reuse เพื่อสร้าง environment หลายชุดได้

template ทำหน้าที่เป็นเอกสารของ infrastructure และสามารถเก็บ history ใน version control เพื่อดูความเปลี่ยนแปลงหรือย้อนกลับเวอร์ชันได้

สามารถ review template/code ก่อน deployment เพื่อลดโอกาสผิดพลาด


🖼️ Source figure — Student Guide p.401; full screenshot is kept in the Google Drive master copy.

Student Guide ยกตัวอย่างการใช้ template เดียวกันสร้าง architecture ที่เหมือนกันใน environment ต่างกัน เช่น Development และ Production หรืออยู่คนละ AWS Region

แนวคิดสำคัญคือ architecture pattern สามารถถูกทำให้ repeatable ได้

ในกรณีที่ environment ต่างกันบางส่วน สามารถใช้ condition/parameter เพื่อเลือกค่าที่เหมาะกับ environment นั้น เช่น AMI ที่ต่างกันใน Development และ Production


🖼️ Source figure — Student Guide p.402; full screenshot is kept in the Google Drive master copy.

ตัวอย่างใน Student Guide คือการเพิ่ม security group ใหม่เข้า application stack โดยแก้ template แล้วใช้ template ที่แก้แล้ว update infrastructure

ข้อดีคือ environment ที่สร้างจาก template เดียวกันสามารถได้รับ change แบบ consistent ลด effort ในการทำ change ซ้ำด้วยมือ


AWS CloudFormation เป็น service ที่ช่วย provision และ manage AWS resources จาก template

🖼️ Source figure — Student Guide p.403; full screenshot is kept in the Google Drive master copy.

Student Guide อธิบาย CloudFormation ในเชิงแนวคิดว่าเป็น API wrapper: เมื่อ template define resource แล้ว CloudFormation จะเรียก AWS service APIs เพื่อสร้างและจัดการ resource ตาม dependencies/relationships

flowchart LR
    T[CloudFormation template]
    CF[AWS CloudFormation]
    API[AWS service APIs]
    S[Stack of resources]
    T --> CF --> API --> S

เราสามารถ author template ด้วย code editor และเก็บ template ใน version control system เช่น GitHub ได้

CloudFormation มีให้ใช้ใน AWS Regions และตัว CloudFormation service เองไม่ได้คิดค่าใช้จ่ายแยกจาก resources ที่ provision


🖼️ Source figure — Student Guide p.404; full screenshot is kept in the Google Drive master copy.

CloudFormation template สามารถเขียนเป็น

  • JSON
  • YAML

Student Guide เน้นว่า template เป็น source code ที่อธิบาย resources ที่ต้องการ create/modify และสามารถ review + version control ได้

  • define application stack ทั้งชุด
  • define runtime parameters เช่น EC2 instance size, AMI และค่าอื่น ๆ
  • import existing AWS resources เข้ามาอยู่ภายใต้ CloudFormation management ผ่าน resource import
  • เก็บใน version control เช่น Git/SVN

แนวคิดสำคัญคือ template คือ desired definition ของ infrastructure


🖼️ Source figure — Student Guide p.405; full screenshot is kept in the Google Drive master copy.

Stack คือ collection ของ AWS resources ที่ CloudFormation template สร้างและจัดการเป็น single unit

ตัวอย่าง resource ภายใน stack อาจมี

  • Amazon VPC
  • Amazon DynamoDB
  • Amazon RDS
  • Amazon EFS
  • Amazon EC2
  • AWS Lambda

CloudFormation สามารถ

  • create stack
  • update stack
  • delete stack

resource ทั้งหมดใน stack ถูก manage ตาม template

Student Guide อธิบายว่า หาก resource creation ล้มเหลว CloudFormation สามารถ rollback และลบ resources ที่สร้างไปแล้วเพื่อให้ stack กลับสู่ state ที่ consistent

เมื่อต้องเปลี่ยน resource ใน stack โดยทั่วไปให้ update stack แทนการลบ stack แล้วสร้างใหม่

Change set ใช้ preview ความเปลี่ยนแปลงก่อน apply โดยเปรียบเทียบ current stack กับ updated template

สามารถ share output จาก stack หนึ่งไปใช้อีก stack ผ่าน cross-stack references ได้


🖼️ Source figure — Student Guide p.406; full screenshot is kept in the Google Drive master copy.

Student Guide แสดง layered architecture ที่แยก stacks ตาม layer เช่น

  • Identity
  • Base network
  • Shared services
  • Backend
  • Frontend

แต่ละ layer สามารถมี lifecycle และ ownership แยกกัน และ layer ด้านบนอาจ depend on resource/output จาก layer ด้านล่าง

flowchart BT
    I[Identity]
    N[Base network]
    S[Shared services]
    B[Backend]
    F[Frontend]
    I --> N --> S --> B --> F

แนวทางนี้ช่วยไม่ต้องเอาทุก resource ในองค์กรไปกองใน CloudFormation stack เดียว


Architecture idea
↓
JSON / YAML template
↓
CloudFormation
↓
Stack
↓
AWS resources

เวลาจะเปลี่ยน infrastructure:

Edit template
↓
Version control / review
↓
Preview changes
↓
Update stack

Topic Key idea
IaC ใช้ code define และ deploy infrastructure
Template desired infrastructure definition
JSON/YAML รูปแบบที่ CloudFormation template รองรับ
Reusability template เดิมสร้าง environment หลายชุดได้
Version control track/change/rollback infrastructure definition
CloudFormation provision/manage AWS resources จาก template
Stack resources ที่ CloudFormation manage เป็น single unit
Change set preview stack changes ก่อน apply
Cross-stack reference share outputs ระหว่าง stacks
Layered stacks แยก lifecycle/ownership ของ architecture แต่ละ layer

หน้า 407 เริ่มหัวข้อ Infrastructure management ซึ่งจะไปต่อใน Part 2


Source: Architecting on AWS 7.12.4 (EN) — Student Guide
PDF pages: 407–426
Scope: Infrastructure management → Elastic Beanstalk → AWS Solutions Library → AWS CDK → Systems Manager → Amazon Q → Review → Knowledge Check


Part 2 ตอบ business request ข้อที่สองของ Module 8:

จะ deploy, maintain และ scale applications ใน cloud ได้อย่างไร?

Student Guide แนะนำ infrastructure/development tools หลายระดับ ตั้งแต่ convenience สูงไปจนถึง control สูง


🖼️ Source figure — Student Guide p.408; full screenshot is kept in the Google Drive master copy.

Student Guide แสดง tools หลักดังนี้

  • AWS Elastic Beanstalk
  • AWS Solutions Library
  • AWS Cloud Development Kit (AWS CDK)
  • AWS CloudFormation
  • AWS Systems Manager

ภาพรวมคือเราต้อง balance ระหว่าง convenience กับ control

service ที่ abstract มากจะใช้ง่ายและ maintenance น้อย แต่ customize ต่ำกว่า ส่วน service ที่ให้ control สูงต้องมี expertise และการจัดการมากขึ้น


🖼️ Source figure — Student Guide p.409; full screenshot is kept in the Google Drive master copy.

Elastic Beanstalk ช่วย deploy และ maintain scalable web applications โดยเรา focus ที่ application code มากกว่าการ provision underlying infrastructure ด้วยตัวเอง

Student Guide ระบุว่า Elastic Beanstalk

  • provisions and operates infrastructure
  • manages application stack
  • แสดง resources ที่ถูกสร้าง
  • automatically scales application up and down

เหมาะกับ web applications และ web services ที่ต้องการ platform ช่วย manage infrastructure


🖼️ Source figure — Student Guide p.410; full screenshot is kept in the Google Drive master copy.

AWS Solutions Library ช่วยแก้ common architecture problems ด้วย solutions ที่ AWS architects จัดทำไว้

Student Guide ระบุว่ามีองค์ประกอบ เช่น

  • CloudFormation templates
  • scripts
  • diagrams / architectural guidance

จุดประสงค์คือใช้ prebuilt architecture patterns และ deployment accelerators เพื่อลดเวลาการเริ่มจากศูนย์


🖼️ Source figure — Student Guide p.411; full screenshot is kept in the Google Drive master copy.

AWS CDK เป็น software development framework สำหรับ define cloud application resources ด้วย programming languages ที่คุ้นเคย

Student Guide ยกตัวอย่างภาษา เช่น

  • Python
  • JavaScript
  • TypeScript
  • Java
  • C#

CDK มี library ของ reusable constructs แล้ว generate CloudFormation templates เพื่อ deploy infrastructure

flowchart LR
    CODE[Application / infrastructure code]
    CDK[AWS CDK]
    T[CloudFormation template]
    CF[CloudFormation]
    S[Stack]
    CODE --> CDK --> T --> CF --> S

CDK ช่วยให้ใช้ features ของ programming language เช่น abstraction/reuse เพื่อสร้าง infrastructure definitions ที่ซับซ้อนได้ง่ายขึ้น


🖼️ Source figure — Student Guide p.412; full screenshot is kept in the Google Drive master copy.

Systems Manager เป็น central place สำหรับ view/manage AWS resources และรองรับทั้ง cloud และ on-premises resources

Student Guide จัดความสามารถเป็นกลุ่ม เช่น

  • provisioning and entitlement
  • configuration management
  • operations and compliance management
  • monitoring

ตัวอย่างงานที่ Student Guide กล่าวถึง

  • สร้าง logical groups ของ resources
  • ดู operational data ผ่าน dashboard
  • inventory / patch / compliance related operations
  • automation งาน maintenance/deployment
  • centrally view/control resources

แนวคิดคือหลัง provision infrastructure แล้ว เรายังต้องมีเครื่องมือช่วย operate และ maintain resources ต่อเนื่อง


หน้า 413 เริ่ม section Amazon Q โดยวางแนวคิดว่าเป็น AI coding companion / generative AI-powered assistant

🖼️ Source figure — Student Guide p.414; full screenshot is kept in the Google Drive master copy.

Student Guide แบ่งตัวอย่าง use cases เป็นสองกลุ่มใหญ่

ออกแบบสำหรับ developers และ IT professionals ใช้ช่วย understand, build, extend และ operate AWS applications

ออกแบบสำหรับ business analysts และ employees ช่วยตอบคำถาม, generate/summarize content และงาน non-coding

Student Guide ยังระบุว่า Amazon Q ถูกออกแบบให้ secure/private by design และสามารถ customize ด้วยข้อมูลขององค์กรตาม use case ได้


🖼️ Source figure — Student Guide p.415; full screenshot is kept in the Google Drive master copy.

Student Guide แสดงว่า Amazon Q Developer ช่วยได้ตลอด software development lifecycle

ช่วยตอบ architecture questions และ provide recommendations

ช่วย generate code / inline recommendations และ assist development

ช่วยเรื่อง tests และ security-related analysis

ช่วย troubleshoot errors และ operational issues

ช่วย code transformation และ modernization

ภาพรวมคือไม่ได้จำกัดอยู่แค่ autocomplete แต่ครอบคลุม workflow ตั้งแต่ plan ไปจน maintain


🖼️ Source figure — Student Guide p.416; full screenshot is kept in the Google Drive master copy.

Amazon Q Developer สามารถ generate code recommendations จาก

  • plain English comments
  • code/context ก่อนหน้า

developer สามารถ accept หรือ reject suggestion ได้

Student Guide ยกตัวอย่างการใช้เพื่อเริ่ม task เช่น data preparation และ iterate ผ่าน recommendations เพื่อเลือก code ที่เหมาะสม


🖼️ Source figure — Student Guide p.417; full screenshot is kept in the Google Drive master copy.

Student Guide แสดง use case ที่ Amazon Q Developer ช่วยวางแผนงานจาก task description และช่วย implement functionality ที่กระทบหลาย files ใน workspace

แนวคิดคือ AI assistant สามารถใช้ context ของ project เพื่อช่วยแตกงานและเสนอ implementation steps


หน้า 419 สรุป solution ของ Module 8 ไว้ว่า

  • ใช้ AWS CloudFormation เพื่อ simplify infrastructure ด้วย IaC
  • ใช้ AWS CDK, AWS Solutions Library และ AWS Elastic Beanstalk เพื่อช่วย deployment/application infrastructure
  • ใช้ AWS Systems Manager เพื่อ automate/manage infrastructure management หลัง deployment

What is an AWS CloudFormation stack?

คำตอบ: All of the provisioned resources that are defined in a CloudFormation template

Student Guide อธิบายว่า stack คือ collection ของ AWS resources ที่ CloudFormation template generate และ manage เป็น single unit

Which statements are benefits of using AWS CDK with AWS CloudFormation? (Select TWO.)

คำตอบตาม Student Guide:

  • Developers can use common programming languages.
  • Developers can call preconfigured resources with proven defaults.

เหตุผลคือ AWS CDK ใช้ familiar programming languages และมี constructs/reusable classes ที่ encapsulate configuration defaults/patterns


flowchart TD
    REQ[Architecture / application requirement]
    IAC[Infrastructure as Code]
    CDK[AWS CDK]
    CFT[CloudFormation Template]
    STACK[CloudFormation Stack]
    DEPLOY[Deployed resources]
    OPS[AWS Systems Manager]
    AI[Amazon Q Developer]

    REQ --> IAC
    IAC --> CFT
    CDK --> CFT
    CFT --> STACK --> DEPLOY
    DEPLOY --> OPS
    AI -.assist plan/create/test/operate/modernize.-> REQ

Need Tool จาก Student Guide
Define infrastructure declaratively CloudFormation
Define infrastructure ด้วย programming language AWS CDK
Managed application platform Elastic Beanstalk
Reuse prebuilt AWS architecture solutions AWS Solutions Library
Operate/configure/manage resources AWS Systems Manager
AI assistance สำหรับ developer/IT workflow Amazon Q Developer

แก่นของ Module 8 คือเปลี่ยนจากการทำ infrastructure แบบ manual ไปสู่ automation ที่ repeatable และ maintainable

Manual infrastructure
↓
Infrastructure as Code
↓
CloudFormation / CDK
↓
Automated deployment
↓
Systems Manager operations
↓
Amazon Q-assisted development and operations

จบ Module 8 ที่หน้า 426 และหน้า 427 เริ่ม Module 9: Containers


เรียนบทหลักตามลำดับ ส่วนลิงก์ด้านล่างเป็นเนื้อหาเสริมหรือแบบฝึก ไม่จำเป็นต้องทำทั้งหมดก่อนบทถัดไป หากต้องการเจาะลึกหรือลงมือทำ ให้เลือกเปิดเฉพาะสิ่งที่เกี่ยวข้องกับเป้าหมาย

🧪 Companion Labs — ไม่ใช่ Official Google Skills Grader

🛠️ Optional Portfolio Projects — เลือกทำเพื่อประสบการณ์ ไม่ใช่ข้อบังคับก่อนสอบ

🗺️ ตารางจับคู่ Modules / Labs / Projects

✅ บทที่ 8/15 ในเส้นทางหลัก

เมื่ออ่านและฝึกทบทวนจบแล้ว ทำเครื่องหมายเพื่อบันทึกใน Browser นี้