Skip to content

Commit

Permalink
Merge pull request #17 from travel-spirit/fix/no-credentials
Browse files Browse the repository at this point in the history
fix: when using roles only (no key and secret), remove also succeeds
  • Loading branch information
palpalani authored Jun 30, 2023
2 parents c8ae833 + f89548e commit 74c8de5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/SqsQueueReaderServiceProvider.php
Original file line number Diff line number Diff line change
@@ -62,16 +62,23 @@ private function removeMessages(array $data, $queue): void
$batchIds = array_column($data['data'], 'batchIds');
$batchIds = array_chunk($batchIds, 10);

$client = new SqsClient([
$config = Config::get('queue.connections.sqs-json');

$sqsClientConfig = [
//'profile' => 'default',
'region' => Config::get('queue.connections.sqs-json.region'),
'version' => '2012-11-05',
'credentials' => Arr::only(Config::get('queue.connections.sqs-json'), ['key', 'secret']),
'http' => [
'timeout' => 30,
'connect_timeout' => 30,
],
]);
];

if ($config['key'] && $config['secret']) {
$sqsClientConfig['credentials'] = Arr::only($config, ['key', 'secret']);
}

$client = new SqsClient($sqsClientConfig);

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

0 comments on commit 74c8de5

Please sign in to comment.