has
profile
=> (
is
=>
'ro'
,
default
=>
sub
{
$ENV
{ AWS_DEFAULT_PROFILE } or
'default'
});
has
credentials_file
=> (
is
=>
'ro'
,
lazy
=> 1,
default
=>
sub
{
my
$self
=
shift
;
if
(
defined
$ENV
{AWS_CONFIG_FILE}){
return
$ENV
{AWS_CONFIG_FILE};
}
else
{
return
$self
->path .
'/'
.
$self
->file_name;
}
});
has
file_name
=> (
is
=>
'ro'
,
default
=>
sub
{
'credentials'
});
has
path
=> (
is
=>
'ro'
,
default
=>
sub
{
return
(File::HomeDir->my_home ||
''
) .
'/.aws/'
;
});
has
_ini_contents
=> (
is
=>
'ro'
,
isa
=>
'HashRef'
,
lazy
=> 1,
default
=>
sub
{
my
$self
=
shift
;
my
$ini_file
=
$self
->credentials_file;
return
{}
if
(not -e
$ini_file
);
my
$ini
= Config::INI::Reader->read_file(
$ini_file
);
return
$ini
;
});
has
_profile
=> (
is
=>
'ro'
,
isa
=>
'HashRef'
,
lazy
=> 1,
default
=>
sub
{
my
$self
=
shift
;
my
$profile
=
$self
->profile;
return
$self
->_ini_contents->{
$profile
} || {};
});
has
credential_process
=> (
is
=>
'ro'
,
lazy
=> 1,
default
=>
sub
{
my
$self
=
shift
;
return
undef
if
(not
defined
$self
->_profile->{ credential_process });
return
Paws::Credential::CredProcess->new(
credential_process
=>
$self
->_profile->{ credential_process },
);
});
sub
access_key {
my
$self
=
shift
;
return
$self
->credential_process->access_key
if
(
defined
$self
->credential_process);
return
$self
->_profile->{ aws_access_key_id };
}
sub
secret_key {
my
$self
=
shift
;
return
$self
->credential_process->secret_key
if
(
defined
$self
->credential_process);
return
$self
->_profile->{ aws_secret_access_key };
}
sub
session_token {
my
$self
=
shift
;
return
$self
->credential_process->session_token
if
(
defined
$self
->credential_process);
return
$self
->_profile->{ aws_session_token };
}
no
Moose;
1;