So, you want to use S3 to handle image uploads? Here's the definitive guide:
Head over to http://aws.amazon.com/s3/ and click on .
During the create account process, make sure you provide payment information, otherwise you won't be able to use S3. There's no registration fee, you will only be charged for what you use, if you exceed the free usage tier.
Creating a user account
Sign in to AWS Management Console and click on to access the AWS Identity and Access Management (IAM) console which enables you to manage access to your AWS resources.
We need to create a user account, so click on the
Users link on the left handside and then the button. Type in a descriptive user name and make sure the "Generate an access key for each User" checkbox is checked.
Here's the critical step: make sure you either download the credentials or you copy and paste somewhere safe both
Access Key ID and
Secret Access Key values. We will need them later.
Once the user is created, we need to set him permission. Select the user you've just created in the upper panel, click on the
Permissions tab in the lower panel and then click the button.
In the "Manage User Permissions" popup, select the radio button and click the select button to manually enter the permission.
Type in a descriptive name for the policy and use the following piece of code as a template for your policy document:
First, some warnings about your bucket name:
Make sure you change both references to "
name-of-your-bucket" with the name of the bucket you will use for your Discourse instance before applying the policy.
Now that you've properly set up S3, the final step is to configure your Discourse forum. Make sure you're logged in with an administrator account and go the Settings section in the admin panel.
Type in "S3" in the textbox on the right to display only the relevant settings:
You will need to:
- Check the "
enable_s3_uploads" checkbox to activate the feature
- Paste in both "
Access Key Id" and "
Secret Access Key" in their respective text fields
- Enter the name of the bucket you've authorized in the "
s3 upload bucket"
region" setting is optional and defaults to "
us-east-1". You should enter the location (eg. eu-west-1, sa-east-1, etc...) that is nearest to your users for better performances.
That's it. From now on, all your images will be uploaded to and served from S3.
Note how you did not have to create your S3 bucket? That's because Discourse will automagically create it for you if it doesn't already exists.