Hi,
I'm trying to deploy to production at AWS EC2. In accordance with the AWS best practices, the instance should have an associated IAM role with the required permissions rather than credentials themselves. We're trying to follow that practice here.
The problem is that with the following configuration:
'upload_s3' => [
'driver' => 's3',
'credentials' => [
'key' => '',
'secret' => '',
'provider' => CredentialProvider::memoize(
CredentialProvider::instanceProfile(),
),
],
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('UPLOAD_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => true,
],
The code is working as expected, but php artisan config:cache is failing with an error:
Your configuration files are not serializable.
// in a trace, there's a mention of some closure
The configuration is pretty big and complex, so caching the config is a must.
I've checked the FilesystemManager::createS3Driver code, it is completely not customizable. The only solution is to roll in a custom S3 driver provider that will inject the instance profile credential provider.
That solution doesn't look good, so I wanted to ask if there are any other workarounds?
Thank you.
P. S. There's a relevant issue at GH: https://github.com/aws/aws-sdk-php/issues/2290 - but it is old and dead, so I thought to ask first.