Experimental project

This is a sandbox project, which contains experimental code for developer use only.

A Drupal 8 port of the Drupal 7 AWS SDK module. Note: this modules uses the 3.x version of the AWS SDK for PHP, thus the 8.x-3.x branch. As the SDK evolves, the 8.x-3.x branch will follow along. If a 4.x version of the SDK is released, a 8.x-4.x branch will track that version. This is different from how versioning was handled in 7.x.

Installation

The Drupal 8 version of AWS SDK uses composer to download the correct version of the SDK (currently 3.15.*). If you are using Composer Manager, execute

composer drupal-update

from your site's root directory. This will merge the root composer.json file with the composer.json file in this module and then download any needed dependencies into the root /vendor directory.

It is not recommended to simply run composer install from within this module's directory. That will leave your with lots of duplicated (and possibly conflicting) dependencies. Instead use the technique, above, or edit the root composer.json file.

You will need to provide your AWS key and secret key to Drupal in order to use the AWS API. There are several ways to do this, each of which will override the previous options.

  • The most simple is to use the configuration form at admin/config/services/awssdk/configuration. However, it can be insecure as anyone who has access to your database or admin permissions on the site will be able to view and edit your key and secret key.
  • These variables can be set in settings.php (or settings.local.php) by adding these lines:
$config['awssdk.configuration']['aws_key'] = '...';
$config['awssdk.configuration']['aws_secret'] = '...';
  • The variables can be set in the server environment variables AWSSDK_KEY and AWKSDK_SECRET. These constants are defined in the Awssdk class.
  • (@TODO:) By using a key storage system such as https://www.drupal.org/project/key
  • Usage Example

    use Drupal\awssdk\Awssdk;
    
    $aws = new Awssdk();
    
    /** @var \Aws\S3\S3Client */
    $s3 = $aws->createS3(['region' => 'us-west-2', 'version' => 'latest']);
    
    $buckets = $s3->listBuckets()->get('Buckets');
    
    $names = [];
    foreach ($buckets as $bucket) {
      $names[] = 'Found an S3 bucket named ' . $bucket['Name'];
    }
    

    Troubleshooting

    If you get an error similar to "AWS HTTP error: cURL error 60: SSL certificate problem: unable to get local issuer certificate", you need to the CURL CA Root Certificates. It can be downloaded from here. Then add the following to your php.ini:

    curl.cainfo = "path/to/cacert.pem"
    

    And reboot your web server.

    Project information

    • Project categories: Integrations
    • Created by mikeker on , updated