guardian / ophan-housekeeper

Lambda to remove Ophan Email Alerts for bouncing email addresses
0 stars 1 forks source link

Fix AWS SdkClientException due to unspecified HTTP client #256

Closed rtyley closed 1 year ago

rtyley commented 1 year ago

After https://github.com/guardian/ophan-housekeeper/pull/254, Housekeeper ran fine locally, but failed when running in the AWS Lambda environment, because sbt-assembly had thrown away META-INF/services/software.amazon.awssdk.http.SdkHttpService, which the AWS SDK uses to work out which HTTP client engine is available. We could try tweaking sbt-assembly's config, but it's probably better to be explicit in the client initialisation code. Note this is the approach we also take in the main Ophan codebase.

https://github.com/guardian/ophan-housekeeper/pull/254#issuecomment-1317303239

https://github.com/aws/aws-sdk-java-v2/issues/446#issuecomment-500604983

Incidentally, triggering invocations of the AWS Lambda is a little fiddly because it expects to receive a big chunk of JSON detailing a bounced email, but thankfully there's a reference example of that JSON in AWS docs. So we can select the 'Publish message' button in the ses-email-bounce-notifications-for-housekeeper topic of SNS to send a test SES message:

image

And we can see this working in the ELK logs!!

image