From 3b435ca5e79925d939a8ac61802570b9f0e4277c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 11 Oct 2019 08:55:22 +0200 Subject: [PATCH] Fix #1669 --- cloud/aws/custom/awscli.pm | 36 ++++++++++++++++++++++-------------- cloud/aws/custom/paws.pm | 16 ++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/cloud/aws/custom/awscli.pm b/cloud/aws/custom/awscli.pm index d3a9e7344..28278f81a 100644 --- a/cloud/aws/custom/awscli.pm +++ b/cloud/aws/custom/awscli.pm @@ -41,20 +41,21 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - "aws-secret-key:s" => { name => 'aws_secret_key' }, - "aws-access-key:s" => { name => 'aws_access_key' }, - "endpoint-url:s" => { name => 'endpoint_url' }, - "region:s" => { name => 'region' }, - "timeframe:s" => { name => 'timeframe' }, - "period:s" => { name => 'period' }, - "statistic:s@" => { name => 'statistic' }, - "zeroed" => { name => 'zeroed' }, - "timeout:s" => { name => 'timeout', default => 50 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'aws' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '' }, - "proxyurl:s" => { name => 'proxyurl' }, + 'aws-secret-key:s' => { name => 'aws_secret_key' }, + 'aws-access-key:s' => { name => 'aws_access_key' }, + 'aws-profile:s' => { name => 'aws_profile' }, + 'endpoint-url:s' => { name => 'endpoint_url' }, + 'region:s' => { name => 'region' }, + 'timeframe:s' => { name => 'timeframe' }, + 'period:s' => { name => 'period' }, + 'statistic:s@' => { name => 'statistic' }, + 'zeroed' => { name => 'zeroed' }, + 'timeout:s' => { name => 'timeout', default => 50 }, + 'sudo' => { name => 'sudo' }, + 'command:s' => { name => 'command', default => 'aws' }, + 'command-path:s' => { name => 'command_path' }, + 'command-options:s' => { name => 'command_options', default => '' }, + 'proxyurl:s' => { name => 'proxyurl' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'AWSCLI OPTIONS', once => 1); @@ -101,6 +102,9 @@ sub check_options { if (defined($self->{option_results}->{aws_access_key}) && $self->{option_results}->{aws_access_key} ne '') { $ENV{AWS_ACCESS_KEY_ID} = $self->{option_results}->{aws_access_key}; } + if (defined($self->{option_results}->{aws_profile}) && $self->{option_results}->{aws_profile} ne '') { + $ENV{AWS_PROFILE} = $self->{option_results}->{aws_profile}; + } if (!defined($self->{option_results}->{region}) || $self->{option_results}->{region} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --region option."); @@ -485,6 +489,10 @@ Set AWS secret key. Set AWS access key. +=item B<--aws-profile> + +Set AWS profile. + =item B<--endpoint-url> Override AWS service endpoint URL if necessary. diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index cdfb8f64b..6d08b1604 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -42,14 +42,14 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - "aws-secret-key:s" => { name => 'aws_secret_key' }, - "aws-access-key:s" => { name => 'aws_access_key' }, - "region:s" => { name => 'region' }, - "timeframe:s" => { name => 'timeframe' }, - "period:s" => { name => 'period' }, - "statistic:s@" => { name => 'statistic' }, - "zeroed" => { name => 'zeroed' }, - "proxyurl:s" => { name => 'proxyurl' }, + 'aws-secret-key:s' => { name => 'aws_secret_key' }, + 'aws-access-key:s' => { name => 'aws_access_key' }, + 'region:s' => { name => 'region' }, + 'timeframe:s' => { name => 'timeframe' }, + 'period:s' => { name => 'period' }, + 'statistic:s@' => { name => 'statistic' }, + 'zeroed' => { name => 'zeroed' }, + 'proxyurl:s' => { name => 'proxyurl' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'PAWS OPTIONS', once => 1);