Sha256: f4b6a967fd051fc0913916c5abf9d8a4ea25c03e6391968f1f2e7fb00248f537
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
require 'chef/knife' require 'aws' class Chef class Knife module RdsBase ''' Base module to be used by All Knife::RDS commands ''' def self.included(base) base.class_eval do option :aws_access_key_id, :short => "-A ID", :long => "--aws-access-key-id ID", :description => "Your AWS Access Key ID", :proc => Proc.new { |key| Chef::Config[:knife][:aws_access_key_id] = key } option :aws_secret_access_key, :short => "-K SECRET", :long => "--aws-secret-access-key SECRET", :description => "Your AWS API Secret Access Key", :proc => Proc.new { |key| Chef::Config[:knife][:aws_secret_access_key] = key } end end APPLY_METHODS = ['immediate', 'pending-reboot'] unless defined?(APPLY_METHODS) def assert_name_args_at_least!(num, error = 'Incorrect number of name args.') unless name_args.size >= num ui.fatal(error) show_usage exit 1 end end # Ensure user is authenticated before proceededing # # Raises ArgumentError def authenticate!(required = [:aws_access_key_id, :aws_secret_access_key]) errors = [] required.each do |k| if Chef::Config[:knife][k].nil? errors << "A valid #{k} is required." end end unless errors.empty? errors.each { |e| ui.error(e) } exit 1 end connect! end # Assert user supplied apply method is valid def assert_valid_apply_method! unless APPLY_METHODS.include?(config[:apply_method]) ui.fatal("Unknown type of apply method #{config[:apply_method]}") exit 1 end end def rds AWS::RDS.new end def connect! AWS.config(aws_access_key_id: config[:aws_access_key_id], aws_secret_access_key: config[:aws_secret_access_key]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
knife-rds-0.0.1 | lib/chef/knife/rds_base.rb |