You are here

public static function AmazonSesClientFactory::createInstance in Amazon SES 2.0.x

Creates an AWS SesClient instance.

Parameters

array $options: The default client options.

\Drupal\Core\Config\ConfigFactory $configFactory: The config factory.

Return value

\Aws\Ses\SesClient The client instance.

File

src/AmazonSesClientFactory.php, line 24

Class

AmazonSesClientFactory
Factory class for AWS SesClient instances.

Namespace

Drupal\amazon_ses

Code

public static function createInstance(array $options, ConfigFactory $configFactory) {
  $settings = $configFactory
    ->get('aws_secrets_manager.settings');
  $options['region'] = $settings
    ->get('aws_region');
  $awsKey = $settings
    ->get('aws_key');
  $awsSecret = $settings
    ->get('aws_secret');
  if (!empty($awsKey) && !empty($awsSecret)) {
    $options['credentials'] = [
      'key' => $awsKey,
      'secret' => $awsSecret,
    ];
  }
  return new SesClient($options);
}