Installation guide
$aws = Aws::factory(array(
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
'region' => 'us-east-1',
));
Using a custom configuration file
You can use a custom configuration file that allows you to create custom named clients with pre-configured settings.
Let's say you want to use the default aws-config.php settings, but you want to supply your keys using a
configuration file. Each service defined in the default configuration file extends from default_settings service.
You can create a custom configuration file that extends the default configuration file and add credentials to the
default_settings service:
<?php return array(
'includes' => array('_aws'),
'services' => array(
'default_settings' => array(
'params' => array(
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
'region' => 'us-west-2'
)
)
)
);
Make sure to include the 'includes' => array('_aws'), line in your configuration file, because this extends
the default configuration that makes all of the service clients available to the service builder. If this is missing, then
you will get an exception when trying to retrieve a service client.
You can use your custom configuration file with the Aws\Common\Aws class by passing the full path to the
configuration file in the first argument of the factory() method:
<?php
require 'vendor/autoload.php';
use Aws\Common\Aws;
$aws = Aws::factory('/path/to/custom/config.php');
You can create custom named services if you need to use multiple accounts with the same service:
<?php return array(
'includes' => array('_aws'),
'services' => array(
'foo.dynamodb' => array(
'extends' => 'dynamodb',
'params' => array(
'key' => 'your-aws-access-key-id-for-foo',
'secret' => 'your-aws-secret-access-key-for-foo',
'region' => 'us-west-2'
)
),
'bar.dynamodb' => array(
'extends' => 'dynamodb',
'params' => array(
'key' => 'your-aws-access-key-id-for-bar',
'secret' => 'your-aws-secret-access-key-for-bar',
'region' => 'us-west-2'
)
Configuring the SDK
26