How to Resolve 429 Errors on 169.254.170.2 IMDS Path When Creating ActionMailer Objects in ActionMailer::DeliveryJob #3218
Unanswered
solomon-maeng
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Are you using aws-sdk-rails and related gems? https://docs.aws.amazon.com/sdk-for-ruby/aws-actionmailer-ses/api/Aws/ActionMailer/SES/Mailer.html I think you can fetch credentials ahead of time using the ECSCredentials class in your config during start up and pass it this way to the client. It will only refresh when near expiration. I don't recall how action mailer creates instances, I will have to double check, but I thought it was once. In this gem we could also consider taking a client configuration option so that a client isn't created each time |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I'm experiencing 429 errors on the 169.254.170.2 IMDS path when executing ActionMailer::DeliveryJob. This happens after enqueuing a large number of jobs using the Sidekiq Adapter with the perform_later approach, and when Sidekiq processes begin executing these enqueued jobs.
Previously, we configured AWS SES authentication using the SMTP method:
Recently, we changed the configuration to use AWS ECS Task Role with SES Assume Role instead of setting SMTP credentials:
Since changing to the Assume Role configuration method, we encounter 429 errors on the 169.254.170.2 IMDS path whenever we send large volumes of emails through ActionMailer::DeliveryJob.
I believe the issue occurs because when classes inheriting from ActionMailer::Base create ActionMailer::DeliveryJob instances that are processed by the Sidekiq Adapter, there's no throttling mechanism in place. When creating ActionMailer objects for mass email delivery, each instance makes requests to the 169.254.170.2 IMDS path to obtain SES permissions through the Credentials Provider Chain, resulting in 429 errors.
If my understanding is correct, how can I resolve this issue by ensuring the SES object is created only once in the ActionMailer object? I want to prevent excessive requests to the 169.254.170.2 IMDS path.
Beta Was this translation helpful? Give feedback.
All reactions