AWS Code Services
AWS มี managed services สำหรับ build, deploy และ orchestrate pipeline ที่เชื่อมกับ IAM, CloudWatch, S3 artifacts และ AWS runtimes ได้โดยตรง
CodeBuild
AWS CodeBuild เป็น managed build service สำหรับ compile code, run tests และสร้าง deployable artifacts ไม่ต้องดูแล build servers เอง และคิดค่าใช้จ่ายตาม build minutes ที่ใช้
version: 0.2
phases:
install:
commands:
- terraform version
build:
commands:
- terraform fmt -check -recursive
- terraform validate
artifacts:
files:
- "**/*"
CodeDeploy
AWS CodeDeploy ช่วย automate application deployments ไป EC2/on-premises, Lambda และ ECS รองรับ deployment patterns เช่น in-place สำหรับ EC2 และ blue/green หรือ traffic shifting สำหรับ Lambda/ECS
CodePipeline
AWS CodePipeline เป็น continuous delivery service สำหรับ model, visualize และ automate release workflow Pipeline ประกอบด้วย stages และ actions เช่น Source, Build, Test, Approval และ Deploy
Artifacts และ permissions
Pipeline artifacts มักเก็บใน S3 และแต่ละ action ใช้ IAM Role เฉพาะงาน ควรแยก role ระหว่าง build, deploy infrastructure และ deploy application เพื่อลด blast radius
Common mistakes
- ให้ CodeBuild role มี admin access ทั้ง account โดยไม่จำเป็น
- ไม่มี manual approval หรือ change record ก่อน production
- ใช้ pipeline เดียว deploy ทุก environment โดยไม่มี environment-specific guardrails
Review questions
- CodeBuild ต่างจาก CodePipeline อย่างไร?
- CodeDeploy รองรับ compute platforms ใดบ้าง?
- ทำไม pipeline actions ควรใช้ IAM roles แยกกัน?