Created
April 9, 2014 17:12
-
-
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```.
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
# -*- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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