Skip to content

Commit

Permalink
Merge pull request #10 from Westwing-Home-and-Living/aws-credentials-…
Browse files Browse the repository at this point in the history
…optional

[WMS-6119]: Make AWS Credentials optional
  • Loading branch information
Jacek Barecki authored Dec 28, 2021
2 parents f284770 + 7071cbe commit c88f278
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 11 additions & 6 deletions src/Adapter/AwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ public function make($config)
$prefix = (!empty($config[Config::INDEX_PREFIX]) ? $config[Config::INDEX_PREFIX] : null);
$options = (!empty($config[Config::INDEX_OPTIONS]) ? $config[Config::INDEX_OPTIONS] : array());

$client = new S3Client(array(
Config::INDEX_CREDENTIALS => array(
$s3ClientConnection = [
Config::INDEX_REGION => $config[Config::INDEX_REGION],
Config::INDEX_VERSION => $config[Config::INDEX_VERSION],
];

if (!empty($config[Config::INDEX_KEY]) && !empty($config[Config::INDEX_SECRET])) {
$s3ClientConnection[Config::INDEX_CREDENTIALS] = [
Config::INDEX_KEY => $config[Config::INDEX_KEY],
Config::INDEX_SECRET => $config[Config::INDEX_SECRET],
),
Config::INDEX_REGION => $config[Config::INDEX_REGION],
Config::INDEX_VERSION => $config[Config::INDEX_VERSION],
));
];
}

$client = new S3Client($s3ClientConnection);

$adapter = new AwsS3Adapter($client, $config[Config::INDEX_BUCKET], $prefix, $options);

Expand Down
2 changes: 0 additions & 2 deletions src/Config/Adapter/AwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ public function getAdapterConfigTreeBuilder()
$node
->children()
->scalarNode(self::INDEX_KEY)
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode(self::INDEX_SECRET)
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode(self::INDEX_REGION)
Expand Down

0 comments on commit c88f278

Please sign in to comment.