Enable Versioning on Amazon S3 bucket using ruby

If you want to enable versioning support for an Amazon S3 bucket, you can use the fog gem.

$ gem install fog
$ irb
irb> require 'fog'
irb> storage = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY})
irb> storage.put_bucket_versioning("your bucket name", "Enabled")

To find out the status of your bucket versioning (can be NIL, if versioning was never used on the bucket, "Enabled" if versioning is currently used, and "Suspended" if versioning was used on that bucket once but is disabled currently).

irb> storage.get_bucket_versioning("your bucket name")
Matthias Marschall almost 11 years ago
This website uses short-lived cookies to improve usability.
Accept or learn more