Skip to content

Commit

Permalink
Read .aws/config
Browse files Browse the repository at this point in the history
  • Loading branch information
Genki Sugawara committed Mar 7, 2015
1 parent ba5b19e commit eb4429f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bin/kumogata
Expand Up @@ -29,8 +29,12 @@ begin

provider = AWS::Core::CredentialProviders::SharedCredentialFileProvider.new(credentials_opts)
aws_opts[:credential_provider] = provider
end

region = provider.send(:load_profile)['region']
if File.exist?(options.config_path) and File.readable?(options.config_path)
ini = AWS::Core::IniParser.parse(File.read(options.config_path))
profile = options.config_profile || 'default'
region = ini[profile]['region']
aws_opts[:region] = region if region
end

Expand Down
2 changes: 2 additions & 0 deletions lib/kumogata/argument_parser.rb
Expand Up @@ -8,6 +8,7 @@ class Kumogata::ArgumentParser
:command_result_log => File.join(Dir.pwd, 'command_result.json'),
:color => $stdout.tty?,
:debug => false,
:config_path => File.expand_path('~/.aws/config'),
}

COMMANDS = {
Expand Down Expand Up @@ -86,6 +87,7 @@ def parse!
opt.on('-r', '--region REGION') {|v| options[:region] = v }
opt.on('' , '--profile CONFIG_PROFILE') {|v| options[:config_profile] = v }
opt.on('' , '--credentials-path PATH') {|v| options[:credentials_path] = v }
opt.on('' , '--config-path PATH') {|v| options[:config_path] = v }
opt.on('' , '--format TMPLATE_FORMAT', supported_formats) {|v| options[:format] = v }
opt.on('' , '--output-format FORMAT', supported_formats) {|v| options[:output_format] = v }
opt.on('' , '--skip-replace-underscore') { options[:skip_replace_underscore] = false }
Expand Down

0 comments on commit eb4429f

Please sign in to comment.