You would be amazed at how flexible Nextcloud is for everyone’s needs. When it comes to storage, Nextcloud allows you to use different storage mediums, such as on-disk or remote object storage. You may already know that Nextcloud supports various storage types as external storage, but setting them as primary storage is different. In this article, I am going to show you how to set up Amazon S3 as primary storage in Nextcloud.
What you need:
- Amazon AWS account with access to S3 and IAM
- A fresh working installation of Nextcloud
So let’s get started.
Create S3 bucket
The first thing we will do is create an S3 bucket. So, log in to the AWS console and go to S3 from the top left-hand side menu. Once there, click the Create new bucket button.
On the create bucket page, enter the bucket name. Choose ACLs enabled from the Object Ownership section, and select Object writer below (refer to the image below).
In the Block Public Access settings, leave it as is. The rest of the options can also be skipped.
Note down the bucket name and region (eu-central-2 in my case).
Create new user in IAM
We need a user to access the bucket securely. For this, we will create a user without console access.
Go to IAM and click on Users. Then, click the Create new user button
Enter the new user’s username and click Next.
On this screen, search for the AmazonS3FullAccess policy and select it. Click Next.
Here, you can review your selections and input. Click Create user once confirmed.
Now, on the Users list page, click on the newly created user and then click Create access key.
Choose Application running outside AWS and click Next.
On the final screen, you will be presented with an Access key and a Secret key. Copy them somewhere safe, we will need them.
Integrate with Nextcloud
Open the config.php
file located in the Nextcloud config directory and paste the following into it, updating the information for the bucket and IAM user as needed.
'objectstore' => [
'class' => '\\OC\\Files\\ObjectStore\\S3',
'arguments' => [
'bucket' => 'Nextcloud-bucket',
'region' => 'eu-central-2',
'key' => 'B25NSUAXASRYAP7P5KI',
'secret' => 'a8INfsaumC+RMyGvrkUZAxz7DiuyyTJpJApNj',
],
],
Save and refresh your Nextcloud page. If everything you have entered is correct, S3 will now be connected.