How To Connect Amazon S3 To WordPress?

How To Connect Amazon S3 To WordPress?

In this post, I show you how to configure WordPress to store shared media files (pictures, videos, etc) on Amazon Simple Storage Service (Amazon S3). Amazon S3 is a managed storage service that provides an affordable, performant, and secure method for storing all kinds of data. The interface between WordPress and Amazon S3 is the WP Offload Media Lite plug-in from Delicious Brains. The plug-in takes any file uploaded to WordPress and copies it over to Amazon S3 where your other WordPress instances can access it.

TechEdutricks.com covers how to install and configure the WP Offload Media Lite plug-in with the following steps:
How To Connect Amazon S3 To WordPress?


  1. Create an Amazon S3 bucket to hold your media files.
  2. Add an AWS Identity and Access Management (IAM) user and policy.
  3. Update the WordPress configuration file with the user credentials.
  4. Install and configure the actual plug-in.
  5. Upload an image to WordPress to test it all out.

1. Create an S3 Bucket

1. From the left-hand menu click Buckets.

2. Near the top right click Create Bucket.
3. Give your bucket a name. Note: All S3 bucket names are globally unique, so you cannot use the same name as the one I use in this blog. Make a note of the name you choose, you need to enter it into your WordPress configuration later in this tutorial.
Choose the region for your bucket. You should create all your resources for this tutorial in the same region, so make a note of which region you choose.

4. Uncheck Block all public access, and then check the last two sub boxes. This is similar to the steps you took in the prior section. Only this time you are setting the policy for this particular bucket instead of the whole account.

5. Check the box to acknowledge that you are making this bucket public.

6. Click Create bucket.

You now have a bucket to store your media files. In the next section, you create an IAM user with the appropriate permissions to copy files from WordPress into the S3 bucket.

2. Create an IAM User

Let’s start by creating the IAM policy.

1. Navigate to the IAM home page.
2. From the left-hand menu click Policies.

3. Near the top left click Create policy.

4. Click the JSON tab.

Clear the contents in the edit box, and paste in the text below. You need to ensure you use the name of the bucket you created in the previous steps where indicated.


"Version": "2012-10-17",

"Statement": [


"Sid": "VisualEditor0",

"Effect": "Allow",

"Action": [











"Resource": [

"arn:aws:s3:::<your bucket name>",

"arn:aws:s3:::<your bucket name>/*"





You need to add your bucket name here “arn:aws:s3:::<your bucket name>”, .

(ex: “arn:aws:s3:::wp-s3-tutorial-bucket”,



5. Click Review policy.
6. Name your policy wp-s3-policy and click Create policy.

3. Now create a new user, and apply the policy you just created to that user.

1. Click on Users from the left-hand menu.

2. Click the Add user button at the top of the page.

3. Give the user a meaningful name, in my example I call it wp-s3-user

4. Check the Programmatic access box

5. Click Next: Permissions

6. Click Attach exiting policy directly and then in the Search box enter wp-s3-policy (without quotes)

7. From the search results check the box next to wp-s3-policy.

8. Click Next: Tags at the bottom of the screen

9. Click Next: Review at the bottom of the screen

10. Click Create User at the bottom of the screen

The next page then loads, and shows you the credentials you need to configure the WP Offload Media Lite plug in.

Click Show under Secret access key and copy and paste both values (Access Key ID and Secret Access Key) into another document so you can reference them later. You can also download a CSV file with the information by clicking the button in the middle of the screen

Important: If you navigate away from this screen, you will not be able to obtain the credentials again and will need to create a new user. Be sure to either download the CSV or temporarily copy and paste both values into another document. Treat these credentials the same way you’d treat any sensitive username / password pair.

Connect Amazon S3 To WordPress?
4. Install and configure the WP Offload Media Lite plugin

I think you already know how to install a plugin to your WordPress? I will tell you only steps how to add plugin without images.

  1. From the left-hand menu click Plugins and Add new.
  2. On the add new plug-in page, enter WP media offload into the search bar.
  3. Click Install Now on the WP Offload Media Lite plugin.
  4. After a few seconds the Install Now button will change to read Activate.
  • Click the Activate
  • You should be back to the WordPress plug-in screen.
  • Scroll down until you find WP Offload Media Lite. It will be near the bottom as the plugins are listed alphabetically. Click Settings.

Next, you must update your WordPress configuration file (wp-config) with the credentials.

1. Log in to your C-Panel.

2. Visit file manager and find the WordPress folder.

3. Then find wp-config file and edit it.

4. Add following code to the bottom

define( 'AS3CF_SETTINGS', serialize( array (

'provider' => 'aws',

'access-key-id' => 'YOUR ACCESS KEY',

'secret-access-key' => 'YOUR SECRET KEY',

) ) );

Add above code before this code.

if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );

5. Enter the name of the bucket you created earlier, and click Save Bucket Settings. Be sure to use your bucket name instead of the one in the image below.

5. Finally Save Bucket Setting and let’s test now.

Upload some media files and check the file URL. On the right-hand side of the screen the File URL should point to your S3 bucket.

Danushka Sanjeewa

Danushka Sanjeewa is a Software engineer with more than 5 years of experience in Android App Development, Web Development, Marketing, Graphic design, Video editing, and WordPress. And also Writer/Founder of TechEduTricks.com.

Leave a Comment