1

I am trying to mock S3 on my local machine, for which I have used localstack. I am using localstack via docker image, which is running successfully on my local machine.

I have followed below URL to setup localstack in my system:

https://onexlab-io.medium.com/localstack-s3-e28ad393c09

I can create S3 bucket and upload and list files from my local machine after setup.

But how to use localstack in Magento 2 in development env. After setting up Magento and localstack whenever I am trying to enable remote storage via below command:

bin/magento setup:config:set --remote-storage-driver aws-s3 --remote-storage-bucket m242_bucket --remote-storage-region us-east-1

it is returning with below error message:

Adapter error: Unable to write file at location: storage.flag. In ConfigSetCommand.php line 151:
            Parameter validation failed

I think this error is due to endpoint URL of S3. We need to set localstack's S3 endpoint here in order to enable remote storage. But I am unable to get any help on google regarding this.

Please someone help me in this.

1
  • Did you find the solution?
    – lemk0
    May 17 at 11:26

1 Answer 1

0

Having just set up remote storage on our live Magento 2.4.3 website following the documentation I had the same issue and like you, assumed it was an endpoint issue.

The missing part was actually a -n parameter on the end of the php bin/magento setup:config:set command.

If you view the documentation page here the command listed at point number 4 of enabling remote storage includes this parameter:

bin/magento setup:config:set --remote-storage-driver="aws-s3" --remote-storage-bucket="<bucket-name>" --remote-storage-region="<region-name>" --remote-storage-prefix="<optional-prefix>" --remote-storage-key=<optional-access-key> --remote-storage-secret=<optional-secret-key> -n

If you view the documentation page here however, on the "Enable remote storage" section, the parameter is missing:

bin/magento setup:config:set --remote-storage-driver="aws-s3" --remote-storage-bucket="myBucket" --remote-storage-region="us-east-1"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.