0

I have a Spring Boot app that uses AWS SDK v2 for Java. I'm using the software.amazon.awssdk.services.sesv2.SesV2Client to do various tasks like add contacts, send emails etc and everything works fine in development. However, I realized that in production I use VPC endpoints for other tasks since the app runs on a private subnet. So I will have to add an endpoint for SES to me VPC Endpoints. I went and looked for an SES endpoint but it looks like the only one offered is com.amazonaws.us-east-1.email-smtp. It looks like its impossible to use SES in the AWS SDK when on a private subnet. For reference, this is the error I get which just reinforces what I'm saying but there may be something else helpful in there to others taking a look at this.

Jul 24 22:46:15 ip-10-0-2-126 web: 2022-07-24 22:46:15.999 DEBUG 1747 --- [nio-5000-exec-6] .m.m.a.ExceptionHandlerExceptionResolver : Using @ExceptionHandler com.oddsapi.odysseyapi.controllers.exceptionhandling.GlobalControllerExceptionHandler#defaultErrorHandler(HttpServletRequest, Exception) Jul 24 22:46:16 ip-10-0-2-126 web: 2022-07-24 22:46:15.999 DEBUG 1747 --- [nio-5000-exec-6] o.s.web.servlet.DispatcherServlet : Failed to complete request: software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: Connect to email.us-east-1.amazonaws.com:443 [email.us-east-1.amazonaws.com/52.5.91.104, email.us-east-1.amazonaws.com/18.206.141.93, email.us-east-1.amazonaws.com/52.20.100.70, email.us-east-1.amazonaws.com/34.230.97.163, email.us-east-1.amazonaws.com/3.217.95.76, email.us-east-1.amazonaws.com/34.237.162.86, email.us-east-1.amazonaws.com/54.164.105.38, email.us-east-1.amazonaws.com/3.220.196.1] failed: connect timed out

As you can see it attempts to connect to the SES endpoints but cant I'm assuming because it has no available VPC endpoint and also no connection to public internet. Are my assumptions that this is currently impossible correct? If so what are my other options here and if it is possible how can I modify my code/configuration to make this work?

EDIT

I read over this stackoverflow question here AWS Fargate - not sending emails from private subnet with SES endpoint and it is the same problem I'm experiencing with the exception that his private subnet using SES is a Fargate container and my private subnet is an app running on an EC2 instance through Elastic Beanstalk. However, I dont think that matters I think whatever the solution is it will work for both use cases. The guy in that question answered it with his own solution in one sentence and it is not very helpful. I use the exact same AWS article that he did as well which is here new-amazon-simple-email-service-ses-for-vpc-endpoints. My case is specific to using the aws-jdk which appears to connect using port 443 as can be seen in the error above. I think my question still stands as it seems based on the one sentence answer he provided that he went with using smtp instead of java aws-sdk. Spring on Fargate cant connect

After_Sunset
  • 674
  • 3
  • 10
  • 25
  • Does this answer your question? [AWS Fargate - not sending emails from private subnet with SES endpoint](https://stackoverflow.com/questions/64989152/aws-fargate-not-sending-emails-from-private-subnet-with-ses-endpoint) – OARP Jul 24 '22 at 23:24
  • Taking a look now however I can see from the title they're run a container in Fargate where as I'm running my app in Elastic Beanstalk however still might be an answer in there i hope! Thanks will take a look and see – After_Sunset Jul 25 '22 at 12:09

0 Answers0