Note

How to move WordPress images to AWS S3 Bucket

I had a WordPress site with images in the wp-content/uploads folder. That WordPress site was shut down, but all my articles on the new site now had broken image links.

I therefore needed a way to host all the images from my old WordPress uploads folder, but keep the same domain so the image links could be fixed. This can be done in AWS, and here's how:

1. Create an S3 Bucket with your site name

To replicate it on AWS, create S3 bucket with the same name as your domain:

2. Use the AWS S3 Sync to Upload

Then, get your WordPress uploads folder (mine looked like below), and use the following command to upload your wp-content folder:

Command:

aws s3 sync wp-content s3://[your domain name]/wp-content

That's probably the fastest way to do it according to this Stackoverflow answer. Once it's done, map your domain to the the S3 Bucket:

3. Link your domain to the folder

Then in your DNS (I'm using Cloudflare), add a CNAME to your domain (or subdomain in my case), pointing to this S3 bucket:

For the target of the CNAME record, structure it like this:

[your domain name].s3.[aws region].amazonaws.com

Here's mine as an example:

wp.prototypr.io.s3.us-east-1.amazonaws.com

That's it, after your DNS propogates, you can see your images at the same old domain, at the same path and url!

I needed to do that because I killed my WordPress site, but my new site was still linking to all the images, and there were 1000s of them!