How to configure remote-storage on Magento 2 to use local S3 storage

939 views Asked by At

Im try'ing connect Magento 2 remote-storage to my local S3 storage.

s3cmd configured to connect https://s3.example.com working properly, can create bucket, send files etc.

Magento 2 have build aws-s3 driver but can't set proper parameters. I try to set something like this, but still not working and S3Client connect only to predefined endpoints (by region)

'remote_storage' => [
                    'driver' => 'aws-s3',
                    'config' => [
                            'endpoint' => 's3.example.com',
                            'bucket' => 'magento',
                            'bucket_endpoint' => true,
                            'region' => 'eu-west-2',
                            'use_path_style_endpoint' => true,
                            'credentials' => [
                                    'key' => 'C****************C',
                                    'secret' => 'R****************2',
                            ],
                            'debug' => true

                    ]

    ],

It's possible to use build in s3 driver to connect private s3 stack ?

1

There are 1 answers

0
Jessica King On

I ran into this issue as well when trying to implement LocalStack for local testing. I had given up thinking that Magento's S3 implementation wouldn't support this, but I took another look with your example.

EDIT: I have this working now in my local, using my LocalStack endpoint. I would expect the same configuration to work with your custom endpoint. The bucket_endpoint configuration in particular was surprising to me, but without this, file uploads failed with an invalid path.

            'bucket' => 'test-local-s3',
            'bucket_endpoint' => false,
            'region' => 'east-1',
            'scheme' => 'http',
            'endpoint' => 'http://localstack:4566',
            'use_path_style_endpoint' => true,
            'credentials' => [
                'key' => 'C****************C',
                'secret' => 'R****************2',
            ],
            'debug' => true,