Cron fails on amazon_ses when not configured

Created on 25 January 2024, 5 months ago
Updated 20 June 2024, 9 days ago

It looks like when the module is enabled but not configured for use (via mailsystem module) it *still* wants working AWS credentials when `drush cron` runs because the Drupal cron implementation insists on creating an AmazonSesMailQueue instance.

I use an IAM role to allow Drupal to generate temporary AWS credentials, but the (non-prod) server is not allowed to get credentials (or in fact send emails to the world :-) and this means that cron always errors out on a Guzzle error. I've added a backtrace below.

I removed the annotation from the AmazonSesMailQueue plugin and that made the error stop; but I guess that's not really a helpful fix. Is there a way to make this code not run when mailsystem is not configured to use amazon_ses?

In RequestException.php line 113:
                                                                                          
  [GuzzleHttp\Exception\ClientException (403)]                                            
  Client error: `POST https://sts.amazonaws.com` resulted in a `403 Forbidden` response:  
  <ErrorResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">                       
    <Error>                                                                               
      <Type>Sender</Type>                                                                 
      <Code>AccessDeni (truncated...)                                                     
                                                                                          

Exception trace:
  at /srv/www/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
 GuzzleHttp\Exception\RequestException::create() at /srv/www/vendor/guzzlehttp/guzzle/src/Middleware.php:72
 GuzzleHttp\Middleware::GuzzleHttp\{closure}() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:209
 GuzzleHttp\Promise\Promise::callHandler() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:158
 GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() at /srv/www/vendor/guzzlehttp/promises/src/TaskQueue.php:52
 GuzzleHttp\Promise\TaskQueue->run() at /srv/www/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php:163
 GuzzleHttp\Handler\CurlMultiHandler->tick() at /srv/www/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php:189
 GuzzleHttp\Handler\CurlMultiHandler->execute() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:251
 GuzzleHttp\Promise\Promise->invokeWaitFn() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:227
 GuzzleHttp\Promise\Promise->waitIfPending() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:272
 GuzzleHttp\Promise\Promise->invokeWaitList() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:229
 GuzzleHttp\Promise\Promise->waitIfPending() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:272
 GuzzleHttp\Promise\Promise->invokeWaitList() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:229
 GuzzleHttp\Promise\Promise->waitIfPending() at /srv/www/vendor/guzzlehttp/promises/src/Promise.php:69
 GuzzleHttp\Promise\Promise->wait() at /srv/www/vendor/aws/aws-sdk-php/src/AwsClientTrait.php:58
 Aws\AwsClient->execute() at /srv/www/vendor/aws/aws-sdk-php/src/AwsClientTrait.php:86
 Aws\AwsClient->__call() at /srv/www/html/modules/contrib/aws/src/Entity/Profile.php:318
 Drupal\aws\Entity\Profile->getTemporaryCredentials() at /srv/www/html/modules/contrib/aws/src/Entity/Profile.php:273
 Drupal\aws\Entity\Profile->getClientArgs() at /srv/www/html/modules/contrib/aws/src/AwsClientFactory.php:50
 Drupal\aws\AwsClientFactory->getClient() at /srv/www/html/modules/contrib/amazon_ses/src/AmazonSesHandler.php:74
 Drupal\amazon_ses\AmazonSesHandler->__construct() at /srv/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:259
 Drupal\Component\DependencyInjection\Container->createService() at /srv/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:177
 Drupal\Component\DependencyInjection\Container->get() at /srv/www/html/modules/contrib/amazon_ses/src/Plugin/QueueWorker/AmazonSesMailQueue.php:33
 Drupal\amazon_ses\Plugin\QueueWorker\AmazonSesMailQueue::create() at /srv/www/html/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php:21
 Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() at /srv/www/html/core/lib/Drupal/Component/Plugin/PluginManagerBase.php:83
 Drupal\Component\Plugin\PluginManagerBase->createInstance() at /srv/www/html/core/lib/Drupal/Core/Queue/QueueWorkerManager.php:62
 Drupal\Core\Queue\QueueWorkerManager->createInstance() at /srv/www/html/core/lib/Drupal/Core/Cron.php:206
 Drupal\Core\Cron->processQueues() at /srv/www/html/core/lib/Drupal/Core/Cron.php:162
 Drupal\Core\Cron->run() at /srv/www/html/core/lib/Drupal/Core/ProxyClass/Cron.php:75
 Drupal\Core\ProxyClass\Cron->run() at /srv/www/vendor/drush/drush/src/Drupal/Commands/core/DrupalCommands.php:69
 Drush\Drupal\Commands\core\DrupalCommands->cron() at n/a:n/a
πŸ’¬ Support request
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia cafuego

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024