0Pricing
AWS for Backend Developers (EC2, S3, RDS, Lambda) · บทเรียน

การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3

ปกป้องข้อมูลด้วยการกำหนดเวอร์ชัน และเพิ่มประสิทธิภาพค่าใช้จ่ายในการจัดเก็บด้วยกฎวงจรชีวิตสำหรับการเปลี่ยนสถานะและการหมดอายุของออบเจ็กต์

การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3 เป็นบทเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AWS for Backend Developers (EC2, S3, RDS, Lambda) มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Protect Your S3 Data

We often store important files in S3. But what if a file is accidentally deleted or overwritten? What if we need older versions?

  • AWS S3 offers powerful features to protect your data and manage it efficiently.
  • This lesson introduces S3 Versioning for data recovery and Lifecycle Policies for cost optimization.
  • These tools help ensure your data is safe and that you're only paying for what you need.

Understand S3 Versioning

  • S3 Versioning keeps multiple versions of an object in the same bucket.
  • When enabled, every time you modify or delete an object, S3 creates a new version instead of overwriting the old one.
  • This acts like a safety net, allowing you to recover from unintended deletions or overwrites.

Each version of an object has a unique version ID.

Turn On Versioning for Buckets

Versioning is configured at the bucket level. Once enabled, it applies to all objects in that bucket.

  • You can enable versioning through the AWS Management Console, AWS CLI, or SDKs.

Important: Versioning cannot be fully disabled once enabled, only suspended. Suspending means new objects won't get new versions, but existing versions remain.

How Object Versions are Stored

When versioning is active:

  • Uploading a new object creates its first version.
  • Uploading an object with the same name creates a new, 'current' version, while the old one becomes a 'non-current' version.
  • Deleting an object doesn't remove it; instead, a 'delete marker' is placed as the current version. The actual object versions are preserved.

You can recover an object by deleting its delete marker or retrieving a specific older version.

Suspend, Don't Disable

Once enabled, S3 Versioning cannot be fully disabled. You can only suspend it.

  • Suspending versioning means new objects uploaded to the bucket will not have new versions created.
  • Existing versions of objects remain in the bucket.
  • If you upload an object with the same name as an existing object after suspension, the new object will overwrite the old object's current version (if it existed), and no new version ID will be generated for the new object.

Optimize Storage with Lifecycles

S3 Lifecycle Policies automate the management of your objects throughout their lifetime.

  • They help you save costs by moving objects to cheaper storage classes (like S3 Standard-IA or Glacier) or by deleting objects that are no longer needed.
  • Lifecycle rules are defined for a specific bucket and can apply to all objects or a subset based on a prefix or tags.

Transition Objects to Cheaper Storage

A common use of lifecycle policies is to transition objects between different S3 storage classes.

  • For example, you might move objects from S3 Standard (frequently accessed) to S3 Standard-IA (infrequently accessed) after 30 days.
  • Then, after 90 days, you might transition them to S3 Glacier (archive storage) for long-term, low-cost retention.
  • This helps balance access needs with cost efficiency.

Expire Objects Automatically

Another key function of lifecycle policies is to expire (permanently delete) objects automatically.

  • You can set a rule to delete objects after a specified number of days from their creation.
  • This is useful for temporary files, logs, or backups that are only needed for a limited time.
  • Expiration rules can also apply to previous (non-current) versions of objects, ensuring old data is eventually cleaned up.

Practical Lifecycle Examples

  • Logs Archiving: Move application logs from S3 Standard to S3 Standard-IA after 30 days, then to Glacier after 90 days, and finally delete after 365 days.
  • Temporary Files: Delete objects in a "temp/" prefix after 7 days.
  • Old Backups: Keep only the last 30 days of daily backups, expiring older ones.

These policies automate compliance and cost management.

Lifecycle with Versioned Buckets

Lifecycle policies work hand-in-hand with versioning. You can define rules for:

  • Current versions: Transition or expire the active version of an object.
  • Non-current versions: Transition or expire older versions of objects. This is crucial for cleaning up after versioning has served its purpose.

For example, you might keep current versions in S3 Standard, but delete non-current versions after 60 days to save storage costs.

Check Your Knowledge

You have an S3 bucket with versioning enabled. You upload image.jpg (Version 1). Later, you upload a new image.jpg (Version 2). What is the state of Version 1 of image.jpg?

Recap: Protect & Optimize

In this lesson, you learned about two crucial S3 features:

  • S3 Versioning: Acts as a safety net, keeping multiple versions of your objects to protect against accidental deletions and overwrites.
  • S3 Lifecycle Policies: Automate cost optimization by transitioning objects to cheaper storage classes and expiring old data, ensuring you only pay for what you need.

Combine these to manage your S3 data effectively!

คำถามที่พบบ่อย

บทเรียน “การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AWS for Backend Developers (EC2, S3, RDS, Lambda) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AWS for Backend Developers (EC2, S3, RDS, Lambda) มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3”

ปกป้องข้อมูลด้วยการกำหนดเวอร์ชัน และเพิ่มประสิทธิภาพค่าใช้จ่ายในการจัดเก็บด้วยกฎวงจรชีวิตสำหรับการเปลี่ยนสถานะและการหมดอายุของออบเจ็กต์ คุณปฏิบัติ AWS for Backend Developers (EC2, S3, RDS, Lambda) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน AWS for Backend Developers (EC2, S3, RDS, Lambda) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) นี้ได้ไหม

ได้ บทเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ทำความเข้าใจบักเก็ตและออบเจ็กต์ของ S3
  2. การกำหนดเวอร์ชันและนโยบายวงจรชีวิตของ S3
  3. การรักษาความปลอดภัยการเข้าถึงข้อมูล S3
  4. การโฮสต์เว็บไซต์สแตติกและการส่งมอบด้วย CDN
← กลับไปที่ AWS for Backend Developers (EC2, S3, RDS, Lambda)