AWS Emulator – ทดสอบ AWS APIs บนเครื่องโดยไม่ต้องมีบัญชี AWS
AWS Emulator เป็นเครื่องมือจำลอง AWS APIs บนเครื่องของคุณ (official จาก AWS) ให้คุณทดสอบโค้ดได้ก่อนขึ้น production โดยไม่ต้องมีบัญชี AWS หรือ deploy ขึ้นระบบจริง รองรับการใช้งานกับ AWS CLI และ AWS SDKs พร้อมวัด fidelity เทียบกับ AWS จริงและเผยแพร่ผลสาธารณะ เหมาะสำหรับทดสอบ control plane operations, IaC (Terraform/CDK), Lambda deployment และใช้งานกับ AI coding agents
คัดมาจาก Telegram · อัปเดต 13 พ.ย. 2569
ส่วนประกอบ
aws · testing · emulator · local-development · ci-cd
AWS Emulator คืออะไร
AWS Emulator เป็นตัวจำลอง AWS APIs ที่รันบนเครื่องของคุณ ช่วยให้คุณทดสอบโค้ดแอปพลิเคชันก่อน deploy ขึ้น AWS ได้ ไม่ว่าจะเป็นการทดสอบบนเครื่อง, ใน CI/CD pipeline หรือขณะพัฒนา prototype ด้วย AI coding agents โดยไม่ต้องมีบัญชี AWS และคำขอของคุณจะไปที่ emulator แทนที่จะไปที่ AWS จริง
AWS Emulator ไม่เสียค่าบริการเพิ่มเติม คุณจ่ายเฉพาะค่า AWS resources ตอน deploy จริงเท่านั้น
ข้อดีสำคัญ
ทดสอบบนเครื่องและใน CI โดยไม่ต้องมีบัญชี AWS
รันทดสอบได้ทันทีบนเครื่องตัวเอง, development server หรือใน CI/CD pipeline โดยทำงานกับ emulated resources แทน AWS resources จริง
ใกล้เคียง AWS มากที่สุดสำหรับ control plane operations
Emulator จำลองการทำงานของ AWS อย่างใกล้เคียงที่สุดสำหรับคำสั่งที่ create, describe, update และ delete resources (control plane operations) โดย operation ที่ implement แล้วจะปฏิเสธคำสั่งที่ไม่ถูกต้องด้วย error แบบเดียวกับ AWS และจะเก็บ state ของ resources ที่สร้างไว้ เพื่อให้คำสั่งถัดไปเห็นการเปลี่ยนแปลงจากคำสั่งก่อนหน้า
ข้อจำกัดสำคัญ: emulator เน้นที่ control plane operations (การจัดการ resources) data plane operations เช่น S3 GetObject, DynamoDB Query อาจไม่ครบหรือแตกต่างจาก AWS จริง นอกจากนี้ emulator ยังไม่รองรับการจำลอง IAM policies แบบเต็มรูปแบบ และการทำงานของ networking ที่ซับซ้อนอาจแตกต่างจาก AWS จริง
ใช้งานกับ AWS CLI และ AWS SDKs ได้เลย
ตั้งค่า environment variables ให้ AWS CLI หรือ AWS SDK ชี้ไปที่ emulator แล้วรันโค้ดตามปกติ สำหรับการทดสอบที่เขียนด้วย Rust กับ AWS SDK for Rust สามารถรัน emulator ภายใน test process ได้โดยตรง
ตัวอย่างการตั้งค่า environment variables:
# ตั้งค่าให้ AWS CLI/SDK ชี้ไปที่ emulator (สมมติรันที่ localhost:8080)
export AWS_ENDPOINT_URL=http://localhost:8080
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
export AWS_REGION=us-east-1
# ทดสอบสร้าง S3 bucket
aws s3api create-bucket --bucket my-test-bucket
# ทดสอบ list buckets
aws s3api list-buckets
ตัวอย่าง use case จริง: ทดสอบ Terraform/CDK stack
# ตั้งค่า environment สำหรับ Terraform
export AWS_ENDPOINT_URL=http://localhost:8080
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
export AWS_REGION=us-east-1
# ทดสอบ Terraform plan/apply กับ emulator
terraform init
terraform plan
terraform apply -auto-approve
# ตรวจสอบ resources ที่สร้างขึ้น
aws s3api list-buckets
aws ec2 describe-instances
ตัวอย่าง use case: ทดสอบ Lambda function ใน CI/CD
# .github/workflows/test.yml
name: Test Lambda
steps:
- name: Start AWS Emulator
run: |
docker run -d -p 8080:8080 public.ecr.aws/aws-emulator/aws-emulator:latest
- name: Test Lambda deployment
env:
AWS_ENDPOINT_URL: http://localhost:8080
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_REGION: us-east-1
run: |
# สร้าง IAM role
aws iam create-role --role-name lambda-role --assume-role-policy-document file://trust-policy.json
# deploy Lambda function
aws lambda create-function \
--function-name my-function \
--runtime python3.12 \
--role arn:aws:iam::123456789012:role/lambda-role \
--handler index.handler \
--zip-file fileb://function.zip
# ตรวจสอบว่า function ถูกสร้าง
aws lambda get-function --function-name my-function
สร้างมาสำหรับ AI coding agents
ติดตั้ง aws-emulator skill แล้ว AI coding agent จะติดตั้ง, เริ่มต้น และเชื่อมต่อ emulator ให้อัตโนมัติ รวมถึงตรวจสอบว่าโปรเจกต์ของคุณใช้งานกับ emulator ได้หรือไม่
วัดความแม่นยำ (fidelity) และเผยแพร่บน GitHub
ความใกล้เคียงระหว่าง emulator กับ AWS จริงเรียกว่า fidelity ทีมพัฒนาตรวจสอบ responses ของ emulator เทียบกับ AWS จริง และเผยแพร่การตรวจสอบใน repository aws-emulator-evaluation-suite พร้อมคะแนน fidelity ในแต่ละ release บน releases page
เปรียบเทียบกับ LocalStack
ถ้าคุณรู้จัก LocalStack อยู่แล้ว AWS Emulator มีจุดแตกต่างหลัก:
| คุณสมบัติ | AWS Emulator | LocalStack |
|---|---|---|
| พัฒนาโดย | AWS (official) | Third-party (open source + commercial) |
| ราคา | ฟรีทั้งหมด | Community (ฟรี) + Pro (เสียเงิน) |
| จุดเน้น | Control plane operations (create, update, delete resources) | Data plane + control plane |
| Fidelity | วัดและเผยแพร่คะแนนสาธารณะทุก release | ไม่มีการวัดเผยแพร่อย่างเป็นทางการ |
| Services ที่รองรับ | ดูรายการใน User Guide เน้น control plane | รองรับ services กว้างกว่า รวม data plane operations หลายอย่าง (S3 GetObject, DynamoDB Query, Lambda execution, etc.) |
| การใช้งาน | เหมาะสำหรับทดสอบ IaC (Terraform, CDK) และ infrastructure code | เหมาะสำหรับทดสอบทั้ง infrastructure และ application logic |
เลือกใช้ AWS Emulator เมื่อ:
- ต้องการความใกล้เคียง AWS จริงสูงสุดสำหรับ control plane operations
- ทดสอบ infrastructure code (Terraform, CDK, CloudFormation)
- ต้องการเครื่องมือ official จาก AWS
- ไม่ต้องการจ่ายเงินสำหรับ premium features
เลือกใช้ LocalStack เมื่อ:
- ต้องการทดสอบ data plane operations (S3 file operations, DynamoDB queries, Lambda execution)
- ต้องการ services ที่หลากหลายกว่า
- ต้องการทดสอบ application logic ที่ต้องใช้ data operations
เริ่มต้นใช้งาน
วิธีติดตั้งและรัน:
ติดตั้งผ่าน Linux package
# ดาวน์โหลด package จาก GitHub releases
# https://github.com/aws/aws-emulator/releases
# ติดตั้ง (Debian/Ubuntu)
sudo dpkg -i aws-emulator_*.deb
# รัน emulator
aws-emulator
รันผ่าน Docker
# รัน emulator container
docker run -p 8080:8080 public.ecr.aws/aws-emulator/aws-emulator:latest
ขั้นตอนการใช้งาน
- เลือกวิธีรัน emulator - ผ่าน AI coding agent, Linux package, Docker หรือ embedded mode (สำหรับ Rust tests)
- ตั้งค่า environment variables - ให้ AWS CLI หรือ SDK ชี้ไปที่ emulator (ดูตัวอย่างด้านบน)
- รันโค้ดทดสอบ - ใช้งานตามปกติ
ข้อมูลเพิ่มเติม
- AWS Emulator User Guide - เรียนรู้รายละเอียด, ข้อจำกัด และ AWS services ที่รองรับ
- Getting started with an AI coding agent - ใช้งานกับ AI coding agent
- Fidelity scores - ดูคะแนน fidelity ของแต่ละ release
- AWS Emulator on GitHub - source code และ issue tracking
- AWS Emulator product page - หน้าผลิตภัณฑ์บนเว็บไซต์ AWS


