Skip to content

Commit 74c8de5

Browse files
authored
Merge pull request #17 from travel-spirit/fix/no-credentials
fix: when using roles only (no key and secret), remove also succeeds
2 parents c8ae833 + f89548e commit 74c8de5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/SqsQueueReaderServiceProvider.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,23 @@ private function removeMessages(array $data, $queue): void
6262
$batchIds = array_column($data['data'], 'batchIds');
6363
$batchIds = array_chunk($batchIds, 10);
6464

65-
$client = new SqsClient([
65+
$config = Config::get('queue.connections.sqs-json');
66+
67+
$sqsClientConfig = [
6668
//'profile' => 'default',
6769
'region' => Config::get('queue.connections.sqs-json.region'),
6870
'version' => '2012-11-05',
69-
'credentials' => Arr::only(Config::get('queue.connections.sqs-json'), ['key', 'secret']),
7071
'http' => [
7172
'timeout' => 30,
7273
'connect_timeout' => 30,
7374
],
74-
]);
75+
];
76+
77+
if ($config['key'] && $config['secret']) {
78+
$sqsClientConfig['credentials'] = Arr::only($config, ['key', 'secret']);
79+
}
80+
81+
$client = new SqsClient($sqsClientConfig);
7582

7683
foreach ($batchIds as $batch) {
7784
//Deletes up to ten messages from the specified queue.

0 commit comments

Comments
 (0)