StorageSection 0612 min read27 questions

S3

Simple Storage Service

Amazon S3 คือ Object Storage ระดับ infinitely scalable เก็บไฟล์ได้ไม่จำกัด มี durability 99.999999999% (11 nines) ใช้สำหรับ backup, DR, archive, hybrid cloud, hosting, media, data lakes, software delivery และ static website นอกจากนี้ AWS ยังมี Snow Family สำหรับ migrate ข้อมูลขนาดใหญ่และ Storage Gateway สำหรับ hybrid cloud เชื่อม on-prem app เข้ากับ S3

ในหน้านี้14 sections
  1. 01S3 Overview
  2. 02S3 Security
  3. 03S3 Static Website Hosting
  4. 04S3 Versioning
  5. 05S3 Access Logs
  6. 06S3 Replication (CRR & SRR)
  7. 07S3 Storage Classes
  8. 08S3 Advanced Features
  9. 09S3 Object Lock & Glacier Vault Lock
  10. 10Shared Responsibility for S3
  11. 11AWS Snow Family
  12. 12AWS Storage Gateway
  13. 13AWS OpsHub
  14. 14Summary
01

S3 Overview

Amazon S3 เป็นหนึ่งในบริการหลักของ AWS โฆษณาว่าเป็น infinitely scaling storage เก็บข้อมูลในรูปแบบ objects ภายใน buckets ใช้กันอย่างแพร่หลายทั่วโลก

  • Buckets — container ระดับบนสุด ชื่อต้อง globally unique ทั่ว AWS (ทุก account, ทุก region)
  • Objects — ไฟล์ที่เก็บใน bucket ขนาดสูงสุด 5TB ต่อ object
  • Object Key = full path ของ object เช่น s3://my-bucket/folder1/folder2/file.txt
  • ไม่มีแนวคิดเรื่อง directory จริงๆ — มีแค่ keys ที่มี prefix ดูเหมือน folder
  • เป็น Regional service — bucket สร้างใน region ที่เลือก แต่ชื่อต้อง unique ทั่วโลก
  • ไฟล์ใหญ่กว่า 5GB ต้องใช้ Multi-Part Upload (แนะนำเริ่มที่ 100MB)

Backup & Storage

เก็บไฟล์ backup ทั่วไป — ทดแทน on-prem storage ได้ทันที

Disaster Recovery

Replicate ข้อมูลข้าม region (CRR) เพื่อรองรับเหตุการณ์ภัยพิบัติ

Archive

เก็บข้อมูลระยะยาวใน Glacier / Deep Archive ราคาถูกมาก

Hybrid Cloud Storage

เชื่อม on-prem app เข้ากับ S3 / Glacier ผ่าน Storage Gateway โดยใช้ NFS, SMB, iSCSI, VTL — มี local cache

Application Hosting

เก็บ static assets ของแอป (JS, CSS, รูป)

Media Hosting

เก็บไฟล์ vdo / รูป ขนาดใหญ่ — scalable มาก

Data Lakes & Big Data Analytics

เก็บ raw data จำนวนมหาศาลให้ Athena / Redshift / EMR ดึงไปใช้

Software Delivery

เผยแพร่ installer / update ให้ผู้ใช้ดาวน์โหลด

Static Website Hosting

Host website ที่ไม่มี backend (HTML, CSS, JS) โดยตรงจาก S3

02

S3 Security

S3 Security แบ่งเป็น User-Based (ใครเข้าได้) และ Resource-Based (resource อนุญาตใคร) — สามารถใช้ร่วมกันได้

User-Based: IAM Policies

กำหนดในระดับ IAM user/role/group ว่า API call ใดบ้างที่อนุญาตสำหรับ user คนนั้นกับ S3

Resource-Based: Bucket Policies

JSON policy ติดที่ bucket — ใช้บ่อยที่สุด อนุญาต cross-account access ได้และ make bucket public ได้

Resource-Based: Object ACL

Access Control List ระดับ object — fine grained (เปิด/ปิดได้ในการตั้งค่า bucket)

Resource-Based: Bucket ACL

ACL ระดับ bucket — พบไม่บ่อยแล้ว (legacy, AWS แนะนำใช้ bucket policy แทน)

กฎ: IAM principal เข้าถึง S3 object ได้เมื่อ (IAM permission อนุญาต OR resource policy อนุญาต) AND ไม่มี explicit DENY

ตัวอย่าง S3 Bucket Policy — อนุญาต public read ทุก object
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-bucket/*"
    }
  ]
}
  • Resources — ระบุ bucket / object ที่ policy มีผล (ARN)
  • Effect — Allow หรือ Deny
  • Actions — API call เช่น s3:GetObject, s3:PutObject
  • Principal — ใคร (account / user / role) ที่ policy นี้มีผลกับ — ใช้ * หมายถึงใครก็ได้ (public)
  • Networking: รองรับ VPC Endpoint เข้าจาก VPC โดยไม่ต้องผ่าน internet
  • Logging & Audit: CloudTrail log API call, S3 Access Logs log การเข้าถึง object
  • User Security: MFA Delete ต้องมี MFA ก่อนลบ object (ใช้ได้เมื่อเปิด Versioning)
03

S3 Static Website Hosting

S3 สามารถ host static website (HTML, CSS, JS, รูป) ได้โดยตรงโดยไม่ต้องมี server — เปิดผ่าน internet ได้ทันที

  • เปิด Static Website Hosting ใน bucket settings
  • กำหนด index document (เช่น index.html) และ error document (เช่น error.html)
  • URL format: http://bucket-name.s3-website-aws-region.amazonaws.com หรือ http://bucket-name.s3-website.aws-region.amazonaws.com
  • Bucket ต้องเป็น public — ต้องปิด Block Public Access และตั้ง bucket policy ให้ allow public read (s3:GetObject)
  • ถ้าไม่ตั้ง bucket policy ที่อนุญาต public read จะได้ 403 Forbidden
04

S3 Versioning

S3 Versioning เก็บ version เก่าของ object ไว้ทุกครั้งที่มีการ overwrite หรือ delete — เปิดได้ที่ ระดับ bucket

  • ทุกครั้งที่ upload ไฟล์ซ้ำชื่อเดิม จะได้ version ID ใหม่ (version เก่ายังอยู่)
  • การ delete จะใส่ delete marker แทนการลบจริง — กู้คืนได้โดยการลบ delete marker ออก
  • ป้องกันการลบโดยไม่ตั้งใจ (unintended deletes) และทำ rollback ได้ง่าย
  • ไฟล์ที่มีอยู่ก่อนเปิด versioning จะมี version ID = null
  • Suspending versioning ไม่ได้ลบ version เก่า — แค่หยุดสร้าง version ใหม่
05

S3 Access Logs

S3 Access Logs ใช้สำหรับ audit purpose — บันทึกทุก request ที่เข้ามาที่ S3 bucket (ทั้ง authorized และ unauthorized)

  • Log จะถูกเขียนไปยัง S3 bucket อื่น (logging bucket) — ไม่ใช่ bucket ตัวเอง
  • บันทึก: ใครเข้า, request type, time, status code, error code, etc.
  • Logging bucket ต้องอยู่ใน region เดียวกัน กับ bucket ที่ถูก log
  • ใช้วิเคราะห์ผ่าน Athena ได้
06

S3 Replication (CRR & SRR)

S3 Replication คือการ copy objects อัตโนมัติ จาก source bucket ไปยัง destination bucket — ต้องเปิด Versioning ทั้งสองฝั่ง

CRR — Cross-Region Replication

Replicate ข้าม region — ใช้สำหรับ compliance, lower latency access จาก region อื่น, replication ข้าม account

SRR — Same-Region Replication

Replicate ภายใน region เดียวกัน — ใช้สำหรับ log aggregation, live replication ระหว่าง production และ test accounts

  • ต้องเปิด Versioning ทั้ง source และ destination
  • Buckets อยู่คนละ AWS account ได้
  • Replication เป็น asynchronous (ไม่ทันที)
  • ต้องให้ IAM permission ที่เหมาะสมกับ S3 (S3 ทำหน้าที่ replicate ในนามคุณ)
  • Object ที่มีอยู่ก่อนเปิด replication จะ ไม่ ถูก replicate อัตโนมัติ — ต้องใช้ S3 Batch Replication
  • Delete operations: replicate delete marker ได้ (optional), แต่ permanent delete พร้อม version ID จะไม่ replicate (กันการ malicious delete)
07

S3 Storage Classes

S3 มี Storage Classes 8 แบบ (Glacier มี 3 sub-tiers) — เลือกตาม ความถี่ในการเข้าถึง, latency และ ค่าใช้จ่าย ที่ยอมรับได้ — ทุก class มี durability 99.999999999% (11 nines) เหมือนกัน

S3 Standard — General Purpose

เข้าถึงบ่อย — availability 99.99%, low latency, high throughput, ใช้กับ big data, mobile/gaming apps, content distribution

S3 Intelligent-Tiering

ย้าย object ระหว่าง tiers อัตโนมัติ ตามการใช้งาน — มี monitoring fee เล็กน้อยแต่ ไม่มี retrieval fee ไม่ต้องคิด lifecycle เอง · เหมาะเมื่อไม่รู้ pattern การเข้าถึง

S3 Express One Zone

High performance — single-AZ, single-digit ms latency, เร็วกว่า Standard ~10x, request cost ถูกกว่า Standard ~80% · เก็บใน directory bucket · เหมาะกับ ML training, analytics ที่ต้องการ latency ต่ำสุด · availability 99.95%

S3 Standard-IA (Infrequent Access)

เข้าถึงไม่บ่อยแต่ต้องการเร็วเมื่อเข้าถึง — availability 99.9%, ค่าเก็บถูกกว่า Standard แต่มี retrieval fee ต่อ GB · ขั้นต่ำ 30 วัน · ใช้กับ DR, backup

S3 One Zone-IA

Infrequent Access แต่เก็บใน AZ เดียวavailability 99.5%, ถูกกว่า Standard-IA ~20% ข้อมูลหายถ้า AZ พัง · เหมาะกับข้อมูลที่สร้างใหม่ได้, secondary backup

S3 Glacier Instant Retrieval

Archive ที่ต้องการ millisecond retrieval — ถูกกว่า Standard-IA ~68% เมื่อเข้าถึงประมาณ ครั้ง/ไตรมาส · ขั้นต่ำ 90 วัน · เหมาะกับ medical images, news media archives, user-generated content

S3 Glacier Flexible Retrieval (formerly S3 Glacier)

Archive ราคาถูก — retrieval มี 3 ระดับ: Expedited 1-5 นาที, Standard 3-5 ชม., Bulk 5-12 ชม. (Bulk ฟรี) · ขั้นต่ำ 90 วัน · เหมาะกับ backup และ DR ที่บางครั้งต้องดึงเร็ว

S3 Glacier Deep Archive

ถูกที่สุด — สำหรับข้อมูลที่แทบไม่เข้าถึง (long-term archive 7-10 ปี) · retrieval: Standard 12 ชม., Bulk 48 ชม. · ขั้นต่ำ 180 วัน · ทดแทน on-prem tape libraries

  • Durability: ทุก class = 99.999999999% (11 nines) — เก็บ 10 ล้าน objects โดยเฉลี่ยจะหาย 1 object ทุกๆ 10,000 ปี
  • Availability: ต่างกันตาม class · Standard 99.99% > Standard-IA 99.9% > One Zone-IA 99.5% · Express One Zone 99.95%
  • Storage in 3+ AZs by default ยกเว้น One Zone-IA และ Express One Zone ที่เก็บใน AZ เดียว
  • ย้าย class ได้ด้วยตนเอง หรือใช้ S3 Lifecycle Rules ย้ายอัตโนมัติตามอายุ object
08

S3 Advanced Features

นอกเหนือจากเก็บไฟล์เฉยๆ S3 มี features สำคัญสำหรับ cost optimization, security, performance และ event-driven workflows ที่ CLF-C02 มักทดสอบ

Encryption (Server-Side & Client-Side)

SSE-S3 AWS managed key (default ตั้งแต่ ม.ค. 2023) · SSE-KMS ใช้ KMS key ของลูกค้า มี audit log ใน CloudTrail · SSE-C ลูกค้าให้ key เอง AWS ไม่เก็บ · Client-Side Encryption เข้ารหัสก่อน upload key ไม่ถึง AWS

Lifecycle Policies

Transition actions ย้าย object ระหว่าง storage classes ตามอายุ (Standard → IA → Glacier) · Expiration actions ลบ object เก่า / version เก่า / incomplete multipart uploads · ฟรี ไม่มีค่า config

S3 Transfer Acceleration

Upload / download เร็วขึ้นจากที่ห่างไกล โดยใช้ CloudFront edge locations เป็นจุดรับและส่งผ่าน AWS backbone ไป bucket · เหมาะกับการรับไฟล์จาก users ทั่วโลกเข้า bucket ใน region เดียว

S3 Select

ใช้ SQL ดึงเฉพาะ subset ของ object (CSV, JSON, Parquet) — ไม่ต้อง download ทั้งไฟล์ · ลด egress cost และ processing time · เหมาะกับ object ไฟล์เดียว (ใช้ Athena สำหรับหลายไฟล์)

Presigned URLs

URL ที่มี signature + วันหมดอายุ ใช้แชร์ object แบบ private ชั่วคราวโดยไม่ต้องเปิด bucket public · default 1 ชม., max 7 วัน (SigV4) · ใช้กับ download หรือ upload ก็ได้

Event Notifications

Trigger Lambda / SNS / SQS / EventBridge เมื่อ object ถูก create / delete / restore / replicate · เป็น foundation ของ event-driven workflow บน S3 (เช่น auto-resize ภาพ, virus scan)

  • VPC Gateway Endpoint for S3 — เข้า S3 จาก VPC ผ่าน AWS backbone โดยไม่ต้องผ่าน internet · ใช้ bucket policy condition aws:SourceVpc บังคับให้เข้าจาก VPC ที่กำหนดเท่านั้น
  • MFA Delete — ต้องใส่ MFA token ก่อนลบ object version (ใช้ได้เมื่อเปิด Versioning) · เพิ่มชั้นป้องกัน accidental หรือ malicious delete
  • Multi-Part Upload — แนะนำเมื่อไฟล์ ≥ 100 MB, บังคับเมื่อไฟล์ ≥ 5 GB · upload เป็น parts แบบ parallel เร็วกว่าและ retry ส่วนที่ fail ได้
09

S3 Object Lock & Glacier Vault Lock

S3 Object Lock และ Glacier Vault Lock ใช้รูปแบบ WORM (Write Once Read Many) — เขียนแล้วลบ/แก้ไม่ได้ในช่วงเวลาที่กำหนด เหมาะกับ compliance

S3 Object Lock

Block delete / overwrite object version เป็นเวลาที่กำหนด หรือ indefinitely · ใช้กับ compliance เช่น financial records, healthcare data — ต้องเปิด Versioning

S3 Glacier Vault Lock

ใช้ WORM กับ Glacier Vault — สร้าง Vault Lock Policy แล้ว lock ห้ามแก้ไขหรือลบนโยบายนี้ตลอดไป · เหมาะ regulatory compliance, data retention

10

Shared Responsibility for S3

S3 ก็ใช้ Shared Responsibility Model เหมือนบริการอื่น — AWS ดูแล infrastructure ส่วนผู้ใช้รับผิดชอบเรื่อง config และ data

AWS รับผิดชอบ

Infrastructure (global security, durability, availability, sustainability) · Configuration และ vulnerability analysis · ความพร้อมของ service-side encryption · Compliance validation · Separation ระหว่าง customer (multi-tenant)

ผู้ใช้รับผิดชอบ

S3 Versioning · Bucket Policies / IAM Policies · Replication setup · Logging and monitoring · Storage Classes selection · Encryption settings (เลือกใช้ SSE-S3 / SSE-KMS / SSE-C / Client-side)

11

AWS Snow Family

AWS Snow Family คือชุดอุปกรณ์ physical portable ที่ highly secure ใช้สำหรับ collect และ process data นอก AWS — ใช้ทั้งงาน data migration เข้าสู่ AWS และ edge computing ในพื้นที่ที่เน็ตไม่ดี

Use cases สองด้าน:

1. Data Migration

ขนข้อมูลจำนวนมากเข้า AWS โดยส่งอุปกรณ์ทางไปรษณีย์ — Snowcone, Snowball Edge

2. Edge Computing

Process data ในที่ที่ไม่มี internet หรือเน็ตช้า เช่น เรือ เหมือง สถานที่ห่างไกล — รัน EC2 Instances + Lambda functions ผ่าน AWS IoT Greengrass

อุปกรณ์ในตระกูล Snow:

Snowcone (& Snowcone SSD)

เล็กที่สุด — น้ำหนัก 4.5 lbs (2.1 kg) · พื้นที่ 8 TB HDD (Snowcone) หรือ 14 TB SSD · ใช้ในที่จำกัดพื้นที่ (drone, IoT, vehicle) · ทนทาน secure rugged

Snowball Edge — Storage Optimized

80 TB HDD capacity · เหมาะกับงาน data migration ขนาดใหญ่ · มี clustering ได้

Snowball Edge — Compute Optimized

42 TB HDD + GPU optional · เหมาะกับงาน edge computing, machine learning, video analytics, local computing

ขั้นตอนการใช้งาน Snow Family (Data Migration):

  • 1. Request Snow device จาก AWS Console
  • 2. AWS ส่งอุปกรณ์มาทางไปรษณีย์
  • 3. ติดตั้ง AWS OpsHub software บนเครื่อง client เพื่อจัดการอุปกรณ์
  • 4. Connect Snow device เข้า network และ copy ไฟล์ เข้าอุปกรณ์
  • 5. Ship อุปกรณ์กลับ AWS
  • 6. AWS โหลดข้อมูลขึ้น S3 bucket ที่ระบุ
  • 7. AWS wipe อุปกรณ์ตามมาตรฐาน NIST
12

AWS Storage Gateway

AWS Storage Gateway คือ hybrid cloud storage service ที่เชื่อม on-prem application เข้ากับ AWS storage ผ่าน protocol มาตรฐาน — NFS, SMB, iSCSI, iSCSI VTL — โดยมี local cache เพื่อ low-latency reads ในขณะที่ข้อมูลส่วนใหญ่อยู่บน cloud · ติดตั้งเป็น VM (VMware, Hyper-V, Linux KVM) หรือ EC2 instance ก็ได้

Storage Gateway มี 3 ประเภท:

Amazon S3 File Gateway

NFS / SMB file share — ไฟล์ถูกเก็บเป็น object ใน S3 · มี local cache สำหรับ hot data · รองรับ Lifecycle ไป Glacier · ใช้ AWS IAM และ bucket policy · เหมาะกับ user file shares, application data, ML training data, database backup (SQL, Oracle, SAP)

Volume Gateway

iSCSI block volumes — ใช้กับ Windows/Linux servers on-prem · เก็บใน S3 + EBS snapshots สำหรับ recovery · มี Cached mode (primary ใน cloud, hot data cache on-prem) และ Stored mode (primary on-prem, async backup เข้า S3)

Tape Gateway

iSCSI Virtual Tape Library (VTL) — ทดแทน physical tape backup ด้วย virtual tapes ที่เก็บใน S3 / S3 Glacier / Deep Archive · ใช้ได้กับ backup software เดิม (Veeam, NetBackup, Backup Exec) · ไม่ต้องเปลี่ยน workflow

  • Local cache ทำให้ on-prem app อ่าน hot data ได้เร็วเหมือน local storage
  • ข้อมูลถูก เข้ารหัสทั้ง in transit (TLS) และ at rest (S3 SSE)
  • Integrate กับ AWS Backup, CloudWatch metrics, CloudTrail audit logs
  • รองรับ WORM (write-once read-many) สำหรับ compliance
  • Charged ตาม storage ที่ใช้ + request + data transfer out — ไม่มีค่า ingest เข้า S3
13

AWS OpsHub

AWS OpsHub คือ software application ที่ AWS แจกฟรี — ใช้จัดการ Snow Family devices ผ่าน GUI แทน CLI เดิม (เมื่อก่อนต้องใช้ command line ยุ่งยาก)

  • ติดตั้งบน laptop / desktop ของผู้ใช้ (Windows, macOS, Linux)
  • Unlock และ configure Snow device แต่ละเครื่อง
  • Drag-and-drop ไฟล์เข้า device
  • Launch และจัดการ EC2 Instances บน Snowball Edge / Snowcone
  • Monitor device metrics (capacity, network, storage)
  • Manage AWS services ที่รันบน device — IoT Greengrass, EC2, S3 compatible storage
14

Summary

  • S3 Buckets vs Objects — global unique name, tied to a region
  • S3 Security — IAM policy, S3 Bucket Policy (public access), S3 Encryption
  • S3 Websites — host static website on Amazon S3
  • S3 Versioning — multiple versions for files, prevent accidental deletes
  • S3 Access Logs — log requests made within your S3 bucket
  • S3 Replication — same-region or cross-region, must enable versioning
  • S3 Storage Classes — Standard, Intelligent-Tiering, Express One Zone, Standard-IA, One Zone-IA, Glacier Instant Retrieval, Glacier Flexible Retrieval, Glacier Deep Archive
  • S3 Advanced Features — Encryption (SSE-S3/KMS/C, Client-Side), Lifecycle, Transfer Acceleration, S3 Select, Presigned URLs, Event Notifications, VPC Gateway Endpoint, MFA Delete
  • S3 Object Lock — WORM model, prevent deletes for a defined time
  • Snow Family — physical devices to transfer data into AWS or run edge computing
  • Storage Gateway — hybrid bridge: S3 File Gateway (NFS/SMB), Volume Gateway (iSCSI), Tape Gateway (VTL)
  • OpsHub — desktop application to manage Snow Family devices
  • Shared Responsibility — AWS handles infra; you handle config, policy, encryption
ทดสอบ

คำถามทบทวน

27 ข้อ — เลือกคำตอบเพื่อดูเฉลยและคำอธิบาย

ข้อ 1 / 10คะแนน 0

A company needs to store archive data that is rarely accessed and accepts retrieval times up to 12 hours. Which storage class is the CHEAPEST?