-
-
Save leighmcculloch/a48f826b97789f8d341d to your computer and use it in GitHub Desktop.
A simple tool that will help you enable MFA Delete feature on your S3 bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'aws-sdk-v1' | |
print "S3 bucket name: " | |
bucket_name = STDIN.gets.chomp | |
print "AWS Access Key ID: " | |
aws_id = STDIN.gets.chomp | |
print "AWS Access Secret Key: " | |
aws_key = STDIN.gets.chomp | |
print "AWS Root MFA Serial: " | |
mfa_serial = STDIN.gets.chomp | |
print "AWS Root MFA Token: " | |
mfa_token = STDIN.gets.chomp | |
print "AWS Endpoint (s3.amazonaws.com): " | |
s3_endpoint = STDIN.gets.chomp | |
s3_endpoint = "s3.amazonaws.com" if s3_endpoint.length == 0 | |
s3 = AWS::S3.new({ | |
:s3_endpoint => s3_endpoint, | |
:access_key_id => aws_id, | |
:secret_access_key => aws_key | |
}) | |
bucket = s3.buckets[bucket_name] | |
bucket.enable_versioning :mfa_delete=>'Enabled', :mfa=>"#{mfa_serial} #{mfa_token}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment