Open navClose nav

Cloud Media Storage with AWS S3

Forestry supports storing your media in your own AWS S3 bucket.,dpr_auto,f_auto,q_80,w_640/

AWS S3 Configuration

The S3 configuration can be rather overwhelming if you’re unfamiliar with the service. For our use case it’s safe to keep the defaults unless mentioned otherwise in the guide below.
  1. Sign up for an AWS account
  2. Log into your dashboard and open the Services dropdown in the top bar, then pick the S3 service.
  3. Click on Create Bucket, name it, remember the Bucket name for later and proceed to the Set Permissions step.
  4. In the Set Permissions step make sure to uncheck the following options:
    • Block new public ACLs and uploading public objects
    • Remove public access granted through public ACLs
  5. Review and create your Bucket.
  6. Create User Credentials for the new Bucket. Open Services and select the IAM service.
  7. Navigate to Users and click on Add User.
  8. Grant Programmatic access to create an _access key ID_ and secret access key.
  9. Choose Attach existing policies directly. You’ll need to click on Create Policy in the Set Permissions step.
  10. Name and set your permissions for your policy. Below is an example of the minimum permissions necessary for Forestry’s Media Library.,dpr_auto,f_auto,q_80,w_640/

  11. Set your newly created policy as your user’s permissions and finish the creation of your new user.,dpr_auto,f_auto,q_80,w_640/

  12. Take note of the Access key ID and the Secret access key and navigate to the Media tab on your site’s Settings in Forestry

  13. Select Amazon S3 as a Media Storage Provider and fill in the Bucket, Access Key and Secret. Click on Save Media Settings. You are now connected to your S3 bucket. You can now upload an image in the Media section to test your connection.,dpr_auto,f_auto,q_80,w_640/

Currently, Forestry needs to be able to upload public objects to your S3 bucket in order to display them in the media library (see Step 4). We plan to remove this requirement in a future update.

You will want to adjust your paths in the Media section to work with S3.

  • Public Path: You should enter the full URL to your S3 bucket.
    https://{{ BUCKET_NAME }}.s3.{{ AWS_REGION }}
    • AWS REGION format (e.g. us-west-2) is consistent across regions with the exception of the us-east-1 (North Virginia) region which can be omitted as it is the default one. (full region list)
      To check your public path, upload a media to your bucket, and check its full URL.
  • Front Matter Path: Activate the toggle in this section to use a different public path when inserting an image into front matter.

Migrating Existing Media

Currently, we are not able to automatically migrate existing media from a Git repo to a user’s AWS S3 Bucket. We recommend logging in to your AWS console, select your Bucket and bulk upload your images there. After the images are in your Bucket, they will also appear in your Media Library in Forestry if they are public.

Unfortunately, for the time being, you will need to manually update your front matter to reassign the new images.

Additional Resources

Here we list a few resources that might be helpful for your S3 implementation. Different from dedicated image services (e.g. Cloudinary), S3 needs some additional setup to make eager and lazy image manipulations possible.

Image Manipulation

Last updated on January 8, 2019