module Thor::Aws
Constants
- DEFAULT_REGION
- DEFAULT_REGION_TIMEOUT
- VERSION
Public Class Methods
included(klass)
click to toggle source
# File lib/thor/aws.rb, line 10 def self.included klass klass.class_eval do class_option(:profile, desc: "Load credentials by profile name from shared credentials file.", aliases: [:p], ) class_option(:access_key_id, desc: "AWS access key id.", aliases: [:k], ) class_option(:secret_access_key, desc: "AWS secret access key.", aliases: [:s], ) class_option(:region, desc: "AWS region.", aliases: [:r], ) class_option(:shared_credentials_path, desc: "AWS shared credentials path.", ) end end
Private Instance Methods
aws_configuration()
click to toggle source
# File lib/thor/aws.rb, line 40 def aws_configuration return @aws_configuration if @aws_configuration @aws_configuration = {} [:access_key_id, :secret_access_key, :region].each do |option| @aws_configuration.update(option => options[option]) if options[option] end @aws_configuration.update(region: own_region) if @aws_configuration[:region].nil? && ENV["AWS_REGION"].nil? if [options.shared_credentials_path, options.profile].any? credentials = Aws::SharedCredentials.new path: options.shared_credentials_path, profile_name: options.profile @aws_configuration.update credentials: credentials end @aws_configuration end
instance_variable_get_or_set(name, object)
click to toggle source
# File lib/thor/aws.rb, line 71 def instance_variable_get_or_set(name, object) instance_variable_get(name) or instance_variable_set(name, object) end
own_region()
click to toggle source
# File lib/thor/aws.rb, line 59 def own_region @own_region ||= begin require "net/http" Timeout.timeout DEFAULT_REGION_TIMEOUT do Net::HTTP.get("169.254.169.254", "/latest/meta-data/placement/availability-zone").chop end rescue DEFAULT_REGION end end