Class: VagrantPlugins::Lightsail::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lightsail/config.rb

Instance Method Summary collapse

Instance Method Details

#get_aws_info(profile, location) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vagrant-lightsail/config.rb', line 76

def get_aws_info(profile, location)
  aws_region, aws_id, aws_secret, aws_token = read_aws_environment

  if aws_id.to_s.empty? || aws_secret.to_s.empty?
    aws_config = ENV['AWS_CONFIG_FILE'].to_s
    aws_creds  = ENV['AWS_SHARED_CREDENTIALS_FILE'].to_s

    if aws_config.empty? || aws_creds.empty?
      aws_config = location + 'config'
      aws_creds  = location + 'credentials'
    end

    if File.exist?(aws_config) && File.exist?(aws_creds)
      aws_region, aws_id, aws_secret, aws_token = read_aws_files(profile, aws_config, aws_creds)
    end

  end

  aws_region = nil if aws_region == ''
  aws_id     = nil if aws_id     == ''
  aws_secret = nil if aws_secret == ''
  aws_token  = nil if aws_token  == ''

  [aws_region, aws_id, aws_secret, aws_token]
end