Skip to content

Access to a Mail Manager ingress endpoint from a private subnet with no direct internet access

1

I want to use SES Mail Manager to receive and send mails, the problem is that for sending mails I need to access the endpoint privately from private subnets without internet access, but according to documentation this is only available for SES via VPC endpoint. Of course, I can use SES endpoint for outgoing mail and Mail Manager ingress endpoint for incoming mail, but I prefer to have a single endpoint for both. Can you please advise me on the best approach?

1 Answer
0

Greeting

Hi wgabsi!

Thank you for bringing up this interesting question! It looks like you're working on accessing SES Mail Manager endpoints privately from a subnet without direct internet access—a challenge many users face when working in secure environments. Let’s dive into a solution that aligns with your preferences while addressing the technical nuances of this use case.


Clarifying the Issue

You’ve described a scenario where you want to use Amazon SES Mail Manager for both sending and receiving mail within a private subnet that has no direct internet access. While SES supports VPC endpoints for outgoing mail, it doesn’t natively provide a VPC endpoint for the Mail Manager ingress endpoint. Your goal of achieving a unified endpoint for both sending and receiving mail is valid but requires some creative configuration, as AWS doesn't directly support this out of the box. Let’s explore a robust solution that adheres to AWS best practices and meets your requirements.


Key Terms

  • Amazon SES (Simple Email Service): A cloud-based email service for sending and receiving emails.
  • VPC Endpoint: A secure connection to AWS services within a VPC without needing internet access.
  • Private Subnet: A network configuration where resources have no direct internet access.
  • Ingress Endpoint: The entry point for incoming requests or data.
  • NAT Gateway: A managed AWS service that allows instances in private subnets to access the internet or other AWS services securely.

The Solution (Our Recipe)

Steps at a Glance:

  1. Set up a VPC endpoint for SES to handle outgoing mail.
  2. Use a NAT Gateway or AWS Lambda function to proxy requests for the Mail Manager ingress endpoint.
  3. Configure the SES Mail Manager and validate your setup.

Step-by-Step Guide:

  1. Set up a VPC Endpoint for SES:

    • In the AWS Management Console, navigate to VPC > Endpoints.
    • Create a new endpoint for the SES service in your desired region.
    • Attach the endpoint to the private subnet and configure security groups to allow SMTP traffic.

    Example CLI command:

    aws ec2 create-vpc-endpoint \
        --vpc-id vpc-12345 \
        --service-name com.amazonaws.us-east-1.email-smtp \
        --subnet-id subnet-67890 \
        --security-group-ids sg-abc123

  1. Proxy Requests to the Ingress Endpoint:
    • Option 1: NAT Gateway:

      • Attach a NAT Gateway to your private subnet.
      • Configure the route table of the subnet to route traffic to the NAT Gateway for internet-bound requests.

      Example:

      aws ec2 create-nat-gateway --subnet-id subnet-67890 --allocation-id eip-12345

      Update route table:

      aws ec2 create-route --route-table-id rtb-67890 --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-12345
    • Option 2: AWS Lambda Function:

      • Create a Lambda function that acts as a lightweight proxy for receiving mail. The function will use the SES API to retrieve mail and forward it to your application.

      Example Python Lambda snippet:

      import boto3
      
      def lambda_handler(event, context):
          ses = boto3.client('ses', region_name='us-east-1')
          response = ses.send_email(
              Source='source_at_example.com',
              Destination={'ToAddresses': ['destination_at_example.com']},
              Message={
                  'Subject': {'Data': 'Test Email'},
                  'Body': {'Text': {'Data': 'Hello from Lambda'}}
              }
          )
          return response

  1. Test the Configuration:

    • Outgoing Mail: Use SES to send a test email and confirm that it is delivered successfully.
    • Incoming Mail: Send an email to your SES-configured domain and verify that it is processed by your NAT Gateway or Lambda function.
    • Use Amazon CloudWatch to monitor logs and ensure no errors occur in the workflow.

    Reference Additional Resources:


Closing Thoughts

This solution combines the robust features of VPC endpoints, NAT Gateways, and Lambda functions to overcome the limitations of SES’s current architecture. While it requires a bit of configuration, it provides a secure and scalable way to manage both outgoing and incoming email traffic for your SES Mail Manager.

AWS architectures are designed to be flexible, and your approach aligns with best practices for private subnets and secure communication. If you run into challenges while setting up any part of this workflow, feel free to share details—I’d be happy to help troubleshoot further.


Farewell

I hope this solution simplifies your setup, wgabsi, and helps you achieve a seamless email flow with Amazon SES. Let me know how it works for you, and happy building! 🚀📧


Cheers,

Aaron 😊

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.