Advantages:
You don’t have to purchase an additional hardware as your space requirements grow.
You receive secure and managed hosting at very low costs.
Your server will have an offsite backup in case something goes wrong.
Ample amount of data can be stored in a bucket.
Requirements:
- Amazon S3 bucket
https://aws.amazon.com/s3/ - Composer- Composer installs S3 module dependencies such as AWS SDK
(https://aws.amazon.com/sdk-for-php/). - S3FS Module: Drupal module is required for getting connected to Amazon S3 bucket.
- Drush
Installation:
Step 1: Run the below composer command or go to https://www.drupal.org/project/s3fs for latest version.
composer require 'drupal/s3fs:^3.0@beta'
After running this command, you will get the following screen:
Drupal 9 S3FS module.
Step 2: Enable S3FS Module, Run Below command to enable the module or you can enable it using Drupal UI.
lando drush en s3fs
Step 3: Login Into Admin Panel and go to /admin/config/media/file-system and configured Amazon Simple Storage Service and click on Save Configuration.
Step 4: Go to /admin/config/development/performance and Disabled css and js aggregation. If you will not do this then admin panel got distorted.
Step 5: Go to settings.php file under /web/sites/default/settings.php and add below line and change configuration accordignally.
$settings['file_private_path'] = 'sites/default/files/public';
$settings['s3fs.access_key'] = 'AccessKey';
$settings['s3fs.secret_key'] = 'SecretKey';
$config['s3fs.settings']['bucket'] = 'BucketName';
$config['s3fs.settings']['region'] = 'RegionName';
$settings['s3fs.upload_as_private'] = TRUE;
$settings['s3fs.use_s3_for_public'] = TRUE;
Step 6: Run below command to Clear Cache
lando drush cr
Step 7: Go to images field storage setting and change your storage location to
Step 8: Go to /admin/config/media/s3fs/actions click on validate, it will show success message if connected to S3 Bucket.