Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using EC2 metadata credentials in the Laravel filesystem

How do I tell the Laravel filesystem layer to use the s3 metadata on an EC2 instance? I don't want to provide hardcoded keys and secrets for my s3 buckets. I'm unclear on what the configuration should look like. When I exclude the key and secret from the filesystem configuration I get the following error

ErrorException
Undefined index: key
like image 959
Stewart Avatar asked Sep 16 '25 19:09

Stewart


1 Answers

The fix is to leave empty placeholder values in place for key and secret. eg, in config/filesystems.php

return [
    'cloud' => 's3',    
    'disks' => [
         's3' => [
             'driver' => 's3',
             'key' => '',
             'secret' => '',
             'region' => env('S3_REGION'),
             'bucket' => env('S3_BUCKET'),
         ],
    ],
];
like image 161
Jonathan Baker Avatar answered Sep 18 '25 08:09

Jonathan Baker