Created
April 19, 2012 22:21
-
-
Save systembell/2424596 to your computer and use it in GitHub Desktop.
Upload IAM Server Certificate
This file contains hidden or 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 'fog' | |
require 'trollop' | |
STDOUT.sync = true | |
opts = Trollop::options do | |
version "#{File.basename($0)} 0.0.1 (c) 2011 Upload IAM Certificate" | |
banner <<-EOS | |
Usage: | |
#{File.basename($0)} [options] | |
where [options] are: | |
EOS | |
opt :cert, "SSL certificate", :type => :string | |
opt :key, "SSL key", :type => :string | |
opt :name, "Name required", :type => :string | |
opt :environment, "Environment required", :type => :string, :default => "development" | |
end | |
Trollop::die :cert, 'is required' if opts[:cert].nil? | |
Trollop::die :key, 'is required' if opts[:key].nil? | |
Trollop::die :name, 'is required' if opts[:name].nil? | |
settings = YAML.load_file("#{ENV['HOME']}/.fog") | |
aws_access_key = settings[:"#{opts[:environment]}"][:aws_access_key_id] | |
aws_secret_key = settings[:"#{opts[:environment]}"][:aws_secret_access_key] | |
ssl_cert = File.open(opts[:cert]).read | |
ssl_key = File.open(opts[:key]).read | |
iam = Fog::AWS::IAM.new({ | |
:aws_access_key_id => aws_access_key, | |
:aws_secret_access_key => aws_secret_key | |
}) | |
cert = iam.upload_server_certificate(opts[:cert], opts[:key], opts[:name]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment