AWS S3 — Encryption

Mart — Tanathip Viriya
2 min readJun 6, 2020

Encryption แบ่งออกเป็น 2 ส่วนคือ

  • In Transit

หรือก็คือ SSL/TLS เมื่อเราใช้ HTTPS download file

  • At Rest

สามารถแบ่งเป็น 2 ส่วนคือ Server-Side Encryption และ Client-Side Encryption

Server-Side Encryption แบ่งออกเป็น

  1. S3 Managed Keys (SSE-S3)
    แต่ละ Object จะโดน encrypt ด้วย unique key ซึ่ง key ที่ใช้เองก็จะถูก encrypt ด้วยเช่นกันจาก Master Key และจะถูกเปลี่ยนไปเรื่อยๆๆโดย Amazon จัดการให้ซึ่งใช้ AES-256 bit encryption
  2. AWS Key Management Service (SSE-KMS)
    เทคนิคนี้เป็นการ Customer Master Keys (CMKs) ร่วมกับ SSE-KMS ซึ่งมีความคล้ายกับ SSE-S3 แต่สิ่งที่แตกต่างก็คือ เรื่องของการแยก permission สําหรับการใช้ CMK ซึ่งเป็นเหมือนกันเพิ่มการป้องกันการใช้ Key ในการเข้าถึง S3 object ของเรา ทําให้เราสามารถ track ได้ว่าใครใช้ Key บ้าง
  3. Server-Side Encryption with Customer Provided Keys (SSE-C)
    อันนี้ Amazon จะจัดการ encryption-decryption ให้ แต่ว่าเราเป็นคนจัดการ key เอง เช่น rotate key เมื่อครบอายุเท่าไร เปลี่ยน key เอง

ส่วน Client-Side Encryption คือ เรา Encrypt file เองก่อนค่อย Upload เข้าไปใน S3

บังคับให้ Encryption ทุกครั้งของการเข้า S3 Buckets

คือทุกครั้งที่เรา PUT request เข้า S3 เราสามารถบังคับให้ทํา encryption ทุกครั้งได้ โดยการเพิ่มข้อมูลเข้าไปใน header

x-amz-server-side-encryption

ซึ่งมี options 2 ตัวคือ

  1. AES256 (SSE-S3 — S3 managed keys)
  2. ams:kms (SSE-KMS — KMS managed keys)

แล้วหลังจากนั้นเราก็แค่ไปสร้าง bucket policies ที่จะรับ request ที่มี parameter ตัวนี้นั้นเอง ซึ่งเราสามารถใช้ policy generator ในการสร้างขึ้นมาก็ได้ https://awspolicygen.s3.amazonaws.com/policygen.html

sample policy generator condition
sample of condition for allowing only server-side-encryption

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response