I want to enable versioning for my s3 bucket object aka nested files inside my bucket.
object = s3.Bucket('ben-uguru').Object('db.sqlite')
object.configure_versioning(versioning=True)
print object
In this case I'd want the file 'db.sqlite' inside the bucket 'ben-uguru' have versioning enabled. However the problem that I get is AttributeError: 's3.Object' object has no attribute 'configure_versioning'
With boto3, check and change versioning state.
import boto3
bucket_name = 'avilpage'
s3 = boto3.resource('s3')
versioning = s3.BucketVersioning(bucket_name)
# check status
print(versioning.status)
# enable versioning
versioning.enable()
# disable versioning
versioning.suspend()
S3 Docs: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#bucketversioning
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With