Configuring & Troubleshooting our Amazon Web Services (AWS) Addon
Covered in this article:
This add-on is available in the Plus, Pro, and Elite editions of MemberPress.
Overview
The MemberPress AWS Add-On will give you the ability to:
- Host private files on Amazon S3
- Provide expiring links to registered members with access to individual files
- Embed Video and Audio files on your WordPress pages & posts using the open source Media Element Player (works in Desktop and Mobile browsers)
- Protect your embedded Audio and Video files from being viewed by non-members
MemberPress AWS can be downloaded from here: MemberPress Add-Ons
What is Amazon AWS?
Amazon Web Services (AWS) is a set of tools provided by Amazon to help people host websites, files and do many other things. Amazon S3 is one of the services offered in Amazon AWS. It allows you to upload, host and protect files and be backed by the reliability, security and speed of Amazon.com! Amazon AWS is widely used by individuals, fortune 500 companies and every other type of entity in between.
You can sign up for Amazon AWS very easily -- it's pay by usage and quite inexpensive.
Uploading Your Files To Amazon S3
Once you've signed up and are accessing your AWS Management Console you can click on the S3 button here:
Then you'll want to create a "Bucket" ... which is basically like a folder:
Make sure your bucket names only contain *lowercase* letters, numbers and dashes, and that it starts & ends with a lowercase letter. You can read more about these restrictions on Amazon's AWS developer resource website.
Once your bucket is in place, you can click on it from within your bucket you can then upload files, create folders and generally organize your files how ever you want:
Alternatively, There are now some services & programs that connect with Amazon S3. A couple of these are Cyberduck (Mac only) and FTP2Cloud (similar to DropBox's interface).
Try to make sure that any of your folder names and files only contain uppercase letters, lowercase letters, numbers or dashes. Please try to avoid spaces & special characters in your folder and file names. While this isn't specifically forbidden by Amazon S3's guidelines, special characters (including spaces) have been known to interfere with MemberPress AWS's ability to work properly.
Retrieving Your Amazon Security Credentials
Before you can start using MemberPress AWS you have to enter the Amazon Security credentials associated with your account into your MemberPress website's Settings page.
To find your security credentials, follow these steps:
- Login to AWS Dashboard.
At the top right, click on the profile dropdown (your username), and select the Security Credentials option.
In the left sidebar, under the Access Management section, choose Users.
Next, click Create User.
On the user details page, add the username you want to use following the username formatting instructions. Click Next to proceed.
Select the Attach Policies Directly option, and search for the AmazonS3ReadOnlyAccess policy.
- Check the box next to AmazonS3ReadOnlyAccess to select it. Click Next to save the policy permissions.
At the bottom of the page, confirm the user creation by clicking the Create User button.
Once you create a user, you'll be redirected back to the Users list. Here, you will see a banner with the View User button. Click it to open the user page.
To create access keys for your new user, click Create access key.
Choose the Third-party service option.
Check the box at the bottom to acknowledge the recommendation, and then click Next.
Leave the Description Tag Value empty, and click the Create Access Key button.
Now, you will see the Retreave access keys page. Your Access Key and Secret Keys will be displayed here. You will need to add this data into MemberPress AWS add-on settings.
- Please note that you will not be able to retrieve these keys later. Thus, it’s recommended that you save them as a file, so you can use them at any time. To do so, click the Download .csv file button.
- Click Done to exit the page.
Now you're ready to add the two AWS keys you created previously, to the AWS add-on settings:
- Log in to your site, and navigate to Dashboard > MemberPress > Settings > AWS tab.
Add your Access Key and your Secret Key to the designated fields.
- Click Update Options to save changes.
Note: It's IMPORTANT to make sure that your buckets and the files in your buckets are not publicly accessible, as that would defeat any protection of direct access to those files.
Using MemberPress AWS
Now that you've got MemberPress and the MemberPress AWS add-on installed, you can start using the following shortcodes in your pages, posts and custom post types:
A shortcode that displays an expiring url to your protected file:
[mepr-s3-url src="coolbucket/coolfile.zip"]
A shortcode that creates a link to an expiring url to your protected file:
[mepr-s3-link src="coolbucket/anothercoolfile.pdf"]Download My E-Book[/mepr-s3-link]
A shortcode that embeds a protected audio file (using an encoded Media Element Player and expiring urls):
[mepr-s3-audio src="coolbucket/coolaudiofile.mp3"]
A shortcode that embeds a protected video file (using an encoded Media Element Player and expiring urls):
[mepr-s3-video src="coolbucket/coolmp4s/coolvideofile.mp4"]
Shortcode Options
Common Options
These options are available for all of the MemberPress AWS shortcodes:
src: This is a way to identify the Amazon S3 bucket and path to the protected Amazon file. These values are formatted "<bucket>/<file path>" -- for example if I had an S3 bucket named 'mycoolzips' and I had a file within that bucket called 'funny.zip' and wanted to create a temporary link or embedded media resource then you'd have an src equal to 'mycoolzips/funny.zip'.
rule: This identifies the id of the rule that should be used to determine whether or not to display the shortcode.Note: The shortcode will not display the unauthorized message. If you want to display the message wrap the aws shortcode in the mepr-active shortcode.
expires: The time that the amazon link will be valid. This can be any value that would be accepted by PHP's time functions. A good example would be "+5 minutes" for a link that expires within 5 minutes or "+30 seconds" for a link expiring in 30 seconds. If omitted, the default is "+5 minutes".
target: Set to "new" to open links in a new tab. This option only applies to the mepr-s3-link shortcode.
download: Set to "force" to force the user's browser to download the file when they click the link instead of opening it in the browser. This option only applies to the mepr-s3-url and mepr-s3-link shortcodes.
mepr-s3-url
This shortcode is used to calculate and print out an Amazon S3 expiring link.
mepr-s3-link
This shortcode is used to calculate an Amazon S3 expiring link and display it as the href of a link. This shortcode needs to wrap the text you want displayed for this link.
mepr-s3-audio & mepr-s3-video
These shortcodes are used to embed protected audio and video files onto your pages and posts. Aside from the expire and rule attributes, and the fact that the src attributes represent file paths for Amazon AWS S3 these shortcodes behave exactly like the audio and video shortcodes built-in to WordPress itself, including the ability to include fallback video files to maximize compatibility across all browsers.
You can also use any of the shortcode attributes supported by WordPress video shortcodes here: https://wordpress.org/support/article/video-shortcode/
Implementing the shortcodes and their parameters:
As the Using MemberPress AWS section above outlines, you can use mepr-s3-url, mepr-s3-link, mepr-s3-audio & mepr-s3-video for the type of file followed by the src parameter to specify the URL of your file. The following is an example link for a file that uses all of the above parameters so you can see how they can be implemented:
[mepr-s3-link src="coolbucket/anothercoolfile.pdf" rule="123" expires="+10 minutes" target="new" download="force"]Download My E-Book[/mepr-s3-link]
Please remember that the target="new"
option can only be used with the mepr-s3-link shortcode, and that download="force"
can only be used for mepr-s3-url and mepr-s3-link shortcodes
Considerations about Audio and Video
Since the underlying links to audio and video content displayed with these shortcodes are expiring links. If any file lasts longer than the expiration time there can be issues with users scrubbing video forward or back.
When determining your expire time take these facts into account:
- The shorter the expiration of the links is the more chance there is for issues with the user experience.
- The longer the expiration of the links is the more chance there is for users to download your video content.
AWS V4 Signatures
Recently Amazon AWS introduced a new way of "signing" expiring urls which they call V4 signatures. The MemberPress AWS add-on now supports V4 signatures. These new signatures are more secure than the original way Amazon has signed expiring urls but are computationally more complex and so we still recommend you stay with the old signature formats if you can. Some newer Amazon AWS regions only support V4 signatures though. If you decide to use V4 signatures you'll need to be prepared to also supply MemberPress AWS with the AWS region that you're using.