Search code examples
amazon-web-servicesversioningbucket

Deactivate versioning on s3 buckets


I activated versioning on my bucket. I used :

aws s3api put-bucket-versioning --bucket my_bucket --versioning-configuration Status=Enabled --endpoint-url https://XXXXXXXXX

Now, I would like to deactivate that versioning on that bucket. So, I have 2 questions :

  • Do I need to use : aws s3api put-bucket-versioning --bucket my_bucket --versioning-configuration Status=Suspended --endpoint-url https://XXXXXXXXX

or do I need to edit the ./lifecycle.json file at the "Status" line ?

{
    "Rules": [
        {
            "ID": "Delete old versions after 90 days",
            "Status": "Enabled",   -> Suspended 
            "Prefix": "",
            "NoncurrentVersionExpiration": {
                "NoncurrentDays": 90
              }
        }
    ]
}

Probably, both solution work?

  • My second question is : will the versions be deleted in the bucket? I mean, is the version with "IsLatest": true, that will be saved?

Bests


Solution

  • Versioning cannot be turned off, it can only be Suspended.

    So, yes, you would use Status=Suspended to deactivate the Versioning process.

    The Lifecycle operation is independent of the bucket's Versioning status. Your lifecycle policy is configured to delete previous versions after 90 days. Leave it with its current configuration and it will continue to expire old versions for the next 90 days. After that, it won't do anything since there are no new versions of objects to expire, so you could then delete the Lifecycle rule. (So, don't change anything for now.)

    If you wish to immediately delete all non-current versions of objects, you could modify the Lifecycle rule and set NoncurrentDays to 1, to make the versions expire (delete) quicker. (I'm not sure if it will work with zero.)