5

All the information that I have read on the AWS S3 Object Versioning specifically mentions this:

Objects stored in your bucket before you set the versioning state have a version ID of null. When you enable versioning, existing objects in your bucket do not change. What changes is how Amazon S3 handles the objects in future requests. The topics in this section explain various object operations in a versioning-enabled bucket.

source

I currently have about 2 TB (370K objects) of data in a bucket. My understanding is that if I turn on versioning now, then future objects will be versioned. My question: What about existing objects? Am I stuck without them being non-versioned or is there a way to version them without downloading/reuploading them? I've not found any info while doing Google Fu so wanted to ping the collective here.

Thanks.

3 Answers 3

6

Sorry man but you're stuck.

The versioning must be enabled to get access to previous versions.

With versioning disabled or with versioning suspended, you can not retrieve changelogs of any sort. The file is simply overwritten.

If a null version already exists in a bucket, the null version is overwritten, as shown in the following figure.

version diagram
(source: amazon.com)

Having no versioning ever enabled follows the same policy. But looks more like this:

no versioning
(source: amazon.com)

Where the object with version ID null simply continues to be overwritten. If AWS had versioning set up by default they would probably run out of space.

Update: the items already in the bucket will immediately start versioning when you enable it.

3
  • 2
    I don't think this answers the question. The existing objects will be versioned going forward. Obviously not backwards. Mar 24, 2016 at 23:35
  • Ahh yes they will start versioning when you turn it on but it won't pick up old revisions or something
    – iSkore
    Mar 25, 2016 at 0:26
  • 1
    Yup, that's what I garnered from reading as well. Existing will be null but will be versioned if a new copy is uploaded. Appreciate the info.
    – Valien
    Mar 25, 2016 at 15:07
4

When you turn on versioning on the bucket, existing objects are not given a version ID. Instead, they will have a version ID of null. Any previous versions are not "automatically restored".

Other than that, existing objects will be versioned as normal in the future.

New objects added to or changed in the bucket will be given a unique version ID.

After versioning is enabled, if you list all versions of an object, you'll notice that the last (oldest) version will have a version ID of null, if that original version existed before versioning was enabled.

0

When you enable versioning on an existing S3 bucket, then versioning does "work" for existing objects (depending on what exactly you're expecting!).

If you delete the old object, it just uses a delete marker. You can restore that old object by deleting the delete marker in the usual way. Here's what I see after deleting:

aws s3api list-object-versions --bucket my-example-bucket --prefix myfile

{
    "Versions": [
        {
            "ETag": "\"0123456789abcdef0123456789abcdef\"",
            "Size": 10,
            "StorageClass": "STANDARD",
            "Key": "myfile",
            "VersionId": "null",
            "IsLatest": false,
            "LastModified": "2020-07-02T12:59:44+00:00",
            "Owner": {
                "DisplayName": "aws-dev",
                "ID": "7930123456789abcdef0123456789abcdef0123456789abcdef0123456789abc"
            }
        }
    ],
    "DeleteMarkers": [
        {
            "Owner": {
                "DisplayName": "aws-dev",
                "ID": "7930123456789abcdef0123456789abcdef0123456789abcdef0123456789abc"
            },
            "Key": "myfile",
            "VersionId": "ABCDEFGHIJKLMN_ABCDEFGHIJKLMNOPQ",
            "IsLatest": true,
            "LastModified": "2020-07-02T13:06:53+00:00"
        }
    ]
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .