Method: MistAws::Iam#initialize
- Defined in:
- lib/mist_aws/iam.rb
#initialize(opts = {}) ⇒ MistAws::Iam
Initializes all you need to access aws resources in a region You can create multiple instances to allow access to multiple regions in one program/recipe
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mist_aws/iam.rb', line 32 def initialize(opts={}) # Ruby 1.9 backwards compatability opts = {profile_name: nil, region: nil, logger: ::Logger.new(STDERR)}.merge(opts) opts.each do |key, value| instance_variable_set "@#{key}", value end # Set by rspec tests that are testing methods called by initialize return if ENV['RSPEC_IGNORE_INITIALIZE'] @region ||= ENV['AWS_REGION'] ? ENV['AWS_REGION'] : 'us-east-1' # Note get_creds also resolves and sets @profile_name as well as # fetching the appropriate credentials based on the value of # profile_name and various Environment Variables @credentials = get_creds(profile_name) @iam_client = ::Aws::IAM::Client.new(credentials: @credentials, region: @region) @iam = ::Aws::IAM::Resource.new(client: @iam_client) end |