laravel-sqs-fifo-queue
laravel-sqs-fifo-queue copied to clipboard
No way to set token via config
Hello, notice this issue when updated to latest AWS SDK version
Environment
Laravel 9 PHP 8.2 AWS SDK: 3.273.0
AWS config example
'sqs-fifo' => [
'driver' => 'sqs-fifo',
'key' => env('AWS_ACCESS_KEY'),
'secret' => env('AWS_SECRET_KEY'),
'token' => env('AWS_SESSION_TOKEN'),
'prefix' => env('SQS_PREFIX'),
'suffix' => null,
'queue' => 'second_lane.fifo',
'region' => 'us-west-2',
'group' => 'default',
'deduplicator' => 'unique',
'allow_delay' => null,
],
Code
return new SqsFifoQueue(
new SqsClient(
Arr::except($config, ['token'])
),
$config['queue'],
$config['prefix'] ?? '',
$config['suffix'] ?? '',
(bool)($config['after_commit'] ?? null),
$group,
$deduplicator,
$allowDelay
);
Problem
AWS SDK require Token to be provided. When no Token provided to AwsClient it uses \Aws\Token\TokenProvider::defaultProvider. It can look for token using some default methods but in some case it could find token somehow as string and fail with error:
Invalid configuration value provided for "token". Expected Aws\Token\TokenInterface|Aws\CacheInterface|array|bool|callable, but got string(488) "...." token: (Aws\Token\TokenInterface|Aws\CacheInterface|array|bool|callable) Specifies the token used to authorize requests. Provide an Aws\Token\TokenInterface object, an associative array of "token", and an optional "expiration" key, false
to use a null token, or a callable token provider used to fetch a token or return null. See Aws\Token\TokenProvider for a list of built-in credentials providers. If no token is provided, the SDK will attempt to load one from the environment.
Because there no way for me to find from where it's coming there also no way to set it manually using config and fix the problem using codebase.
Possible Solution
Make token setable form the config: When token present on top level config use it not only for token field in credentials but also for token array itself