Moving WordPress Media to AWS S3

by | Aug 15, 2017

Photo | Pexels

There are a few reasons you may want to move your WordPress media to AWS S3 storage. You may have a huge amount of media, you may want to share media between multiple WordPress installs, or, like me, you may have increased the image file size limit from the measly 2M, to 128M for those sweet high-res images. Whatever the reason, moving files to S3 is simple.
First, you’ll need this handy plugin as well as this one. For more functionality, especially with multiple sites, you’ll need the upgrade from the S3 Lite version.. Second, but just as important, you need an AWS account from which you can create keys, create buckets and read from/write to S3 buckets. So create some keys using IAM in your AWS Console, and store them somewhere you’ll remember.
You only get one shot at obtaining your Access Secret Key when you setup your keys. So don’t screw it up! But if you do you can just delete the keys, and start again. The worst that could happen would be for someone to get your keys. There are a few safe guards I used to help prevent this happening. First I created a new user specifically for the WordPress to S3 function. This user only has Read/Write from the WordPress media bucket. So if the worst was to happen, we only lose a bucket of images and media. Next, I made sure I stored the keys in 1Password to retain them and secure them.
To actually get the keys to your WordPress site so it can connect to AWS, you’ll need to dig into your config files. Using FTP, locate your config file in /var/www/html/wp-config.php and add the lines:

define( ‘DBI_AWS_ACCESS_KEY_ID’, ‘**Your Access Key Here**’ );
define( ‘DBI_AWS_SECRET_ACCESS_KEY’, ‘**Your Secret Key Here**’ );

For the AWS plugin, that’s all you need to do.
Setting up S3 Offload is even easier. Simply create a new bucket with a globally unique name, or select an existing bucket and you’re done! So whether you’re lightening the load on your server, or adding redundant protection to your WordPress install, you now know how to move your media files to a S3 bucket.
From hard data to fluid design – Scott

We love using AWS. You can read all of our AWS Blogs here.

Submit a Comment

Your email address will not be published. Required fields are marked *