-
-
Save xionon/7773682 to your computer and use it in GitHub Desktop.
Simple rake task to upload a cookbooks archive to S3, for use with OpsWorks
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
S3_ACCESS_KEY_ID='SOME_SECRET_ID' | |
S3_SECRET_ACCESS_KEY='SOME_SECRET_KEY' | |
S3_BUCKET_NAME='SOME_BUCKET_NAME' |
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
source 'https://rubygems.org' | |
gem 'rake' | |
gem 'aws-sdk' | |
gem 'dotenv' |
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
require 'aws-sdk' | |
require 'dotenv/tasks' | |
desc "Upload ./tmp/cookbooks.tar to S3" | |
task :upload do | |
AWS.config( | |
:access_key_id => ENV['S3_ACCESS_KEY_ID'], | |
:secret_access_key => ENV['S3_SECRET_ACCESS_KEY'] | |
) | |
s3 = AWS::S3.new | |
bucket_name = ENV['S3_BUCKET_NAME'] | |
file_name = 'tmp/cookbooks.tar' | |
key = File.basename(file_name) | |
print "Upload file #{file_name} to bucket #{bucket_name}. " | |
s3.buckets[bucket_name].objects[key].write(:file => file_name) | |
puts "Success!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment