S3 Versioning
S3 Versioning
Using Versioning with S3
- Stores all versions of an object. (including all writes and even if you delete an object)
- Great backup tool.
- Once enabled, Versioning cannot be disabled, only suspended.
- Intergrate with Lifecycle rules.
- Versioning’s MFA DELETE capability, which uses multi-factor authentication, can be used to provide an additional layer of security.
建立 S3 Bucket Versioning
先建立一個新的 S3 Bucket,如果有遺忘的部分可以參考上篇 AWS - S3 Bucket + Encryption 的部分,可先設成 Public!

再來上傳第一版本的檔案吧!(這邊以 txt 檔來做範例,記得也設定成 Public 才可以看到)
1 | |

完成基本的上傳與設定後,我們要來開啟 Versioning 的功能,點選 Properties 可以看到 Versioning 的框框,這時只要選取到 Enable versioning 並且 Save 就可以開啟。

將原本上傳的檔案把內容稍微更動一下並且再次上傳
1 | |
或許剛剛上傳錯檔案想要刪除,結果就發現 Bucket 裡面的 files 都不見了?明明還有上個版本、上上個版本呀?


眼尖的你應該其實就已經發現兩個問題:
- 在上述開啟
Versioning的時候,S3 Bucket 裡面就有多出Versions Hide/Show的按鈕 - 更改內容再次上傳檔案後或者刪除,txt 檔案真的文字更動了,但是上個版本、上上個版本跑去哪裡了呢?
把 Versions Show 打開,就能看見到底做了什麼!

可以發現剛剛的刪除,其實不是真正的刪除,居然有一個版本是在做刪除這件事情把它蓋過去。
所以這邊又衍生出了一個新議題,如果我真的想退回上個版本該怎麼做才能達成?
必須在 Versions Show 的狀況下,做 Actions 才能達成退版本的效果,不然只是又新增另一個版本上去而已!

總結
- Stores all versions of an object. (including all writes and even if you delete an object)
- Once enabled, Versioning cannot be disabled, only suspended.
- Intergrate with Lifecycle rules.
- Versioning’s MFA DELETE capability, which uses multi-factor authentication, can be used to provide an additional layer of security.