Last updated 23 March 2016. Created on 13 December 2011.
Edited by margyly, SurendraYellu, owenpm3, mototribe. Log in to edit this page.

The AmazonS3 module allows the local file system to be replaced with S3. Uploads are saved into the drupal file table using D7's new file/stream wrapper system.

You can switch it on as the default file system scheme, or individually for file and image fields.

It includes support for Amazon Cloudfront as well, through the use of a CNAME.

Requirements for 1.x Version

AWS SDK for PHP
Libraries API (2.0-alpha2)

Installation and Configuration of the 2.x Version

Install the module and libraries:

  1. Create an S3 bucket for your site. If it's a multisite, create a bucket for each site. If you use dev/stage/live environments, create one for each environment for each site. Set the permissions to make the files world-readable by configuring the IAM user.
  2. Install the AmazonS3 and Composer Manager modules.
  3. Apply the various patches needed for AmazonS3 (see the main module page for details), via Drush Patchfile (https://bitbucket.org/davereid/drush-patchfile). It's a good idea to save a patchfile for re-applying to your patches directory as something like amazons3.patches.make.
  4. Add configuration settings to your settings.php file(s) to use /lib/org as the composer "root" directory (the location of composer.json and the vendor dir).
  5. Enable the Amazons3 module via Drush for testing. (Later, add it as a dependency in your site's profile.)
  6. Run `drush composer update` from the `lib/org` dir.
  7. Add all the new modules, patched files, and Composer vendor libraries to your Git repository. (Note: Adding vendor libs is not standard practice unless it can't be avoided. You may need it in order to deploy to your server, but make sure none of the modules included .git dirs, which would cause issues with submodules).
  8. Upload all your files to your S3 buckets using s3cmd at the Acquia command line, with command that look like this:
    s3cmd sync -r --no-check-md5 --no-delete-removed --acl-public FILES-DIRECTORY/ s3://BUCKETNAME/
    Don't forget the trailing slashes on both the directory name and the bucket name so that your directory strucure is preserved.

Configure Drupal:

  1. Set your Amazon S3 credentials at admin/config/media/amazons3
  2. Change the default download method to "Amazon Simple Storage" at admin/config/media/file-system.
  3. Update the field settings all of your image fields to use S3 storage and update your features with the change.
  4. Turn on the appropriate caching options on the S3 module.
  5. Run a SQL UPDATE to replace references to the public file system with S3 with a statement like this: update file_managed set uri = REPLACE(uri,"public://","s3://BUCKETNAME/") WHERE uri LIKE "public://%";

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.