Skip to content

Instantly share code, notes, and snippets.

@delphyne
Created April 9, 2014 17:12
Show Gist options
  • Save delphyne/10293239 to your computer and use it in GitHub Desktop.
Save delphyne/10293239 to your computer and use it in GitHub Desktop.
Vagrantfile snippet that allows you to use protected s3 boxes without having to go through the manual download/add shennanigans. Tested with Vagrant 1.4.3. Before using, you'll need to ```vagrant plugin install aws-sdk```.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_plugin "aws-sdk"
def get_box_download_url(bucket, key)
s3 = AWS::S3.new
bucket = s3.buckets[bucket]
box = bucket.objects[key]
url = box.url_for(:read, {:expires => (60*30), :secure => true})
url.to_s()
end
bucket='your-s3-bucket'
box='the-name-of-your-box'
key="path-to-box/#{box}.box"
Vagrant.configure("2") do |config|
config.vm.box = box
config.vm.box_url = get_box_download_url(bucket, key)
end
@debo
Copy link

debo commented Oct 30, 2014

Hi @delphyne thanks a lot for the snippet it saved my day. I have one question though. Where is the 'aws-sdk' plugin documented? Google didn't seem particularly helpful. Thanks, Debo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment