I have had an S3 bucket for awhile but only now turned versioning on. Experimenting with it a bit trying to figure out what sort of detection protections I am getting with just the versioning on, without activating the "MFA delete" option.
I uploaded a test file, then deleted it then re-uploaded it twice. Now, using the S3 browser tool I am seeing 4 versions of the file: #1, #2 (deleted), #3 and #4 (current). If I use boto
to get the latest version, I can extract its version_id
:
import boto
c=boto.connect_s3()
b=c.get_bucket('my-bucket')
k = b.get_key('test2/dw.txt')
print k.version_id
But how do i get a full list of version_id's for a given key? And if I want to retrieve version #1 of the key (deleted), do I need to do something first using the version #2 id to "undelete" it?
Finally, does this deletion protection (creation of a delete marker) work with legacy files that had been uploaded before versioning was turned on?
Thx
bucket.list_versions()
and then loop over all the keys the way you show and test for a match ofversion.name
and the name of the key I am interested in? That seems like a strange design decision on the part of AWS/boto folks, although maybe there is something that justifies it that I don't understand... – Brose