healthengine / laravel-easy-aws
Cache dynamic AWS credentials
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- aws/aws-sdk-php: ^3.155
- aws/aws-sdk-php-laravel: ^3.0
- laravel/framework: ^13.27
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-19 05:27:22 UTC
README
This is an extension to the Laravel AWS SDK that provides cacheable
dynamic credentials - such as those provided by the EC2 Metadata API. This is necessary if you want to
php artisan config:cache whilst also not using hard coded credentials - since Laravel is unable to cache the Guzzle
promise that resolves to credentials when used.
It also binds certain AWS client objects to the Laravel container so you can typehint the specific clients you need,
instead of using the AWS facade. Clients are added as needed and we welcome PRs so if you need one that is missing,
please contribute.
Installation
composer require healthengine/laravel-easy-aws
Usage
There's not much to it. You can now typehint the S3Client directly and it will be resolved instead of having to use
the facade to construct the S3 client:
// before $s3 = AWS::createClient('s3'); // after $s3 = app(Aws\S3\S3Client::class);
Credentials are resolved automatically using the default provider chain from the AWS SDK. The only difference is that
they will be cached using Laravel's AwsCredentialCache. This really only helps if that credentials chain ended up
resolving credentials from the EC2 Metadata API, otherwise it would have been using hardcoded credentials of some kind
and caching them doesn't help much.
You can configure which cache store to use by setting the environment variable EASYAWS_CACHE_STORE to any built in
Laravel cache drivers.
Note
Caching credentials can be insecure. Be careful if you are going to use an external cache driver like Redis or database as the credentials are stored in plaintext.
Retries
All clients use the AWS SDK's standard retry mode.
SQS Queue
This package no longer overrides Laravel's sqs queue connector. To cache SQS credentials, enable Laravel's built-in
credential cache on the connection in config/queue.php:
'sqs' => [ 'driver' => 'sqs', // ... 'credential_cache' => [ 'enabled' => true, 'store' => 'file', // any cache store ], ],
Laravel's SQS connector defaults both timeouts to 60 seconds. Set queue.connections.sqs.http.connect_timeout and
queue.connections.sqs.http.timeout to change them.
License
Laravel Easy AWS is licensed under the MIT license.