Skip to content

Commit

Permalink
Support credentials files inside $LAMBDA_TASK_ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jul 13, 2024
1 parent 20d5d93 commit c81f9f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ AWS Core change log

## ?.?.? / ????-??-??

## 2.2.0 / 2024-07-13

* Included `LAMBDA_TASK_ROOT` in home directory lookup - @thekid

## 2.1.0 / 2024-07-07

* Merged PR #12: Support for SSO credential provider - @thekid
Expand Down
9 changes: 7 additions & 2 deletions src/main/php/com/amazon/aws/credentials/FromConfig.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ class FromConfig extends Provider {
public function __construct($config= null, $credentials= null, $profile= null) {
$this->config= new IniFile($config
?? Environment::variable('AWS_CONFIG_FILE', null)
?? new Path(Environment::homeDir(), '.aws', 'config')
?? new Path($this->homeDir(), '.aws', 'config')
);
$this->credentials= new IniFile($credentials
?? Environment::variable('AWS_SHARED_CREDENTIALS_FILE', null)
?? new Path(Environment::homeDir(), '.aws', 'credentials')
?? new Path($this->homeDir(), '.aws', 'credentials')
);
$this->profile= $profile ?? Environment::variable('AWS_PROFILE', 'default');
}

/** @return string */
private function homeDir() {
return Environment::variable(['HOME', 'USERPROFILE', 'LAMBDA_TASK_ROOT'], DIRECTORY_SEPARATOR);
}

/** @return ?com.amazon.aws.Credentials */
public function credentials() {
$modified= max($this->config->modified(), $this->credentials->modified());
Expand Down

0 comments on commit c81f9f5

Please sign in to comment.