Data. Files. They’re what make up your website. And how you store and serve them can make all the difference for user experience. Obviously, cloud storage has changed the way we look at and manage data. So much so that we’ve gone from mostly concerning ourselves with the security element, to grading on speed, security, easy data access and scalability. Today, we’re going to walk through one of the more popular options for Drupal websites.

S3 (Simple Storage Service) is the cloud storage service provided by AWS (Amazon Web Services) and it has been providing durable, secure and scalable cloud storage for many industries. Deploying a Drupal website on Amazon S3 further enhances its speed, performance, security and content delivery. It’s especially beneficial when you have a lot of content files and data that is distributed across multiple servers as Drupal’s default file system might not be able to serve under these circumstances.

It’s easy to work with too. Drupal provides a module that will allow you to upload data from your site directly to Amazon S3. Let’s find out more about S3 and how you can store and serve files from it on your Drupal website.

Amazon S3

Why Amazon S3?

Today companies are looking at parking and retrieving massive scales of their data in a secure way. Amazon S3 provides an extremely robust and reliable cloud storage architecture that offers tons of benefits:

  • Highly Durable - Amazon S3 is designed for 99.999999% durability. Data is stored redundantly across three zones (on separate power substations) and are separated by miles. So even if any one of them gets unavailable, your data is still protected. You also have the ability to replicate your data to any other region.
  • Security and Compliance - It supports three forms of encryption and integration with a machine learning service that can automatically discover and protect sensitive data. It also supports many security standards and compliance certifications like FedRamp, DSS among others. 
  • Low Cost -  When compared to other storage systems, Amazon S3 costs much less. 
  • Easy Data Management - Amazon S3 provides features that allow the ability to configure access permission to your data. Storing, inventorying and classifying data is very easy and flexible
  • Scalable - Customers can store any amount of data. AmazonS3 automatically scales up as you add data into it, ensuring fast performance.
  • Easy Querying - Anyone who knows SQL can run sophisticated big data analytics without needing you to move data to another analytics platform. You can query through the vast amounts of data right from the cloud.

Before you start

Now let’s begin setting up our Drupal website integration with S3. But before we move ahead and upload data from your Drupal site to Amazon S3 you need some prep work. You will need to install some modules. The modules will provide configuration to add the AWS details. You are also required to set up an AWS account.

  • S3 file system - gives you an additional file system to help you store files in Amazon S3. You can set this as your default file system instead of using Drupal’s file system.
  • S3 filesystem CORS upload - allows you to upload and store files from your browser directly to S3 (bypassing Drupal’s file system) and works in conjunction with the S3 file system module. 
  • AWS account (see next)

Creating your AWS account

Setting up an AWS account is easy. Start by giving some basic details like email. 

After logging in you need to create a security key for your account. For that, go to your account and click on Security Credentials.

Access Key

 

On the security details page, click on Access keys (access key ID and secret access key) where it will ask you to create an access key.

Once you create the access key it will ask you to download the credentials. It is recommended to download it for future use.

Configuring the S3 bucket in AWS

The S3 bucket is like a storage container for all data and files stored in S3. Now let’s begin configuring the bucket.

In AWS, search for S3 and click on the bucket.

Services

 

Now, create an S3 bucket.

After creating the bucket, give permissions to the bucket. By default, public access will be blocked. If you don’t want to block all public access, you can choose under what circumstances it can be accessed. For that, will need to give permissions as shown in the below screenshot.

Bucket Setting

Configuring the S3 module in Drupal

As mentioned previously, make sure you first install the S3 module to configure Amazon S3 in your Drupal site.

S3 Module

Now, go to “/admin/config/media/s3fs” in order to configure the S3 module.

S3 Setting

It is always recommended to keep your S3 configuration settings in your settings.php file since it is confidential.

In settings.php file add below details.

$settings['s3fs.access_key'] = '**************************';
$settings['s3fs.secret_key'] = '********************************';
$config['s3fs.settings']['bucket'] = 'techxbucket';
$config['s3fs.settings']['region'] = 'ap-south-1';
$settings['s3fs.use_s3_for_public'] = FALSE;
$settings['s3fs.upload_as_private'] = TRUE;

These are details that we got while creating AWS security details and S3 bucket. Make sure you add the above details.

Configuring upload fields

Now that we have configured our Amazon S3, let’s look at applying the S3 storage to our upload fields. So instead of getting stored in the public file system, it gets stored in the S3 file system. Head to the field settings of any upload field of your Drupal site. You will now see that you have two options for the Upload destination - Public Files and S3 File System (as shown below).

Upload destination

Now when you select S3 File System and then upload a file, it will upload it to the S3  bucket. And the file directory is as configured in the field. When you hover on the file now it will display the S3 path (bottom left of the below screenshot) from where the file is served.

Document

Contact us

LET'S DISCUSS YOUR IDEAS. 
WE'D LOVE TO HEAR FROM YOU.

CONTACT US SUBMIT RFP