Amazon Simple Storage Solution (S3)
Enterprise solutions from Netflix to Ancestry.com are built on S3. They depend on its 99.99999% uptime to deliver content continuously and at tremendous scale world wide. Serving and storing files is what S3 is all about.
Any organization that has been operating for even the shortest period of time has digital storage needs and challenges. S3 is tailor made to service and solve those challenges.
So let’s take a brief look at what S3 is in detail and then we will move on to the step by step of using S3 in our example.
S3 In Detail
Simple Storage Service, S3, really is all about storing and serving files. Whether those files are documents, audio, video, or backups S3 holds them in the cloud and delivers them back to you when you request them. Because of the simplicity of what S3 does it makes it very easy to integrate with a variety of solutions.
S3 offers different levels of performance based on need. If you are using it to safely house backups for use in a disaster recovery scenario then S3 offers a level of storage that is reliable and secure but not quite as fast on delivering files back when requested.
On the other hand, if you have built a global customer base that is consuming video on demand all around the globe, as Netflix has, S3 offers quick a level of service that insures the fastest delivery of files possible to anyone that has requested them. S3 is still storing and delivering files in both scenarios but has been optimized for the needed solution.
For this lesson we are going to use S3 to solve two specific business problems. We are going to simplify recovery in a disaster scenario and we are going to improve the performance of our website by delivering content via S3.
Let’s get started with the step by step.
S3 Step by Step
Step One: Create an S3 Bucket
Log into the AWS console and select the S3 service from the Services drop down menu.
This screen lists all of the S3 buckets you’ve created for your account. Click the “Create Bucket” menu to start building your first S3 bucket.
You will need to supply a unique name for your bucket. This isn’t just unique to your account, it has to be unique in all the world of all S3 buckets. The reason is because this name will be part of a URL used to access the contents of the bucket. That URL must be unique.
Also, a bucket name can’t be changed once it has been created. So choose your name wisely.
After entering your bucket’s name select the region you want it to reside it, usually the one closest to the users that will be retrieving the files in the bucket.
Click the “Next” button.
This will bring up the “Set Properties” screen of the bucket creation wizard. For this lesson the defaults will serve our purposes. Click the “Next” button.
This screen allows you to customize permissions on the bucket and even allow another AWS account to access the bucket. No changes are needed for this lesson. Accept the defaults and click the “Next” button.
The final screen lets you review your choices and go back if you need to make any changes. If everything looks satisfactory click the “Create Bucket” button to finish the wizard and create your S3 bucket.
You now have an S3 bucket to store files in and retrieve them from the cloud.
Step Two: Configure WordPress to use S3
At this point the web server that we’ve been building since lesson two has one major drawback. Any images or videos that have been uploaded are housed on a single server, the same server that is housing the website. So with each file you upload to the server you’re eating up some of its storage space.
So just add more right? Well… You could do that, but the storage you would be adding to the server isn’t optimized to deliver files across the globe. It’s also a good bit more expensive than S3 would be. And lastly, you will need to keep manually adding more storage each time you approach your limit on the server. S3 solves all three of these problems in one easy stroke.
We’re going to use two plugins for WordPress to solve this issue. The Amazon Web Services plugin and the WP Offload S3 Lite pugin. Both are from Delicious Brains at https://deliciousbrains.com/ (no affiliation, I just use their plugins and highly recommend them).
Bring up your WordPress site and log into the Admin console.
Click the plugins link in the navigation panel. Click the “Add New” button.
Enter “Amazon Web Services” in the search box and click the install button for it when it shows up in the search result list.
Once it has finished installing click the “Access Keys” link. You will see a screen to enter your AWS access keys which the plugin will use to connect to your AWS account and your S3 bucket. This means you will need to create an access key with the necessary security. Here’s how.
In the AWS console select the IAM service.
You will need to create a new User Identity that you will grant access to S3 services. Click the users link in the navigation panel. Click the “Add User” button.
Give the user a name to indicate what it is used for, something like “s3-bucket-svc-account”. Check the “Programmatic Access” check box and click the “Next: Permissions” button.
Instead of granting access directly to the user we will create a group that has S3 permissions and add this user to that group. That way, if we ever need to delete this user or add additional users we can simply remove or add them to the group and not need to configure permissions for each individual user.
Click the “Create Group” button to get started.
Give the group a name that will help you remember what it is for, for example “s3-access-users”.
You will also attach the pre-defined access policy that grants permissions to the S3 service. Type S3 in the policy search box. Select the “AmazonS3FullAccess” policy.
Click the “Create Group” button.
You will return to the “Add User” wizard with the new group selected. Click the “Next: Review” button.
Confirm everything looks correct and click the “Create User” button.
You will see a confirmation that the user has been successfully created. Click the “Download .csv” button to download the user’s security credentials. Store this file in a safe location.
You will see the “Access Key ID” displayed and the “Secret Access key” masked with asterisks. Copy the Access Key ID to your clipboard and return to the WordPress plugin Access Keys page on your website. Paste the Access Key ID into the proper text box.
Switch back to the AWS user page and click the “Show” button for the “Secret Access Key”. Copy that value and paste it into the Secret Access Key text box on your WordPress site.
Click the “Save Changes” button on your WordPress site.
Click the Plugins link in the navigation panel in WordPress. Enter “WP Offload S3 Lite” in the search box. Click the install button for this plugin when it appears in the search result list.
Once it is installed click the settings link. At the top of the settings page click the “Change Bucket” button.
This will bring up a list of your AWS S3 buckets. Click the bucket you created earlier.
Click the “Save Changes” button and you will be all set. All of the files you upload to your website will be published to your S3 bucket and served to your site visitors from there instead of your web server.