mercredi 12 mai 2021

Laravel file upload to S3 with implicit AWS key and secret not working

I have hosted my Laravel app on an AWS EC2 instance and I tried to push a file from laravel to a S3 bucket.

EC2 instance has Ubuntu OS and have installed AWS CLI.And EC2 instance has attached an IAM role with full S3 permissions. Therefore, I need to push the file from Laravel to S3 without giving AWS key and secret values.

Additionally, I tried to push a file from EC2 to S3 with AWS CLI and it works fine.

Like this.

aws s3 mv filename.txt s3://bucket-name

But with Laravel it doesn't work.

Following is my Laravel filesystems.php S3 driver array.

's3' => [
        'driver' => 's3',
        'key' => null,
        'secret' => null,
        'region' => 'myregion',
        'bucket' => 'mys3bucket',
        'url' => 'mys3bucketurl',
        'endpoint' => 'mys3bucketurl',
    ],

The same code is working with Laravel 'local' driver in my lcoalhost without an issue.

As I'm aware Laravel supports Implicitly provided AWS credentials key and secret.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire