Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ses] Add VPC Endpoint for SES #9386

Open
followben opened this issue Aug 1, 2020 · 9 comments
Open

[ses] Add VPC Endpoint for SES #9386

followben opened this issue Aug 1, 2020 · 9 comments
Labels
@aws-cdk/aws-ses Related to Amazon Simple Email Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@followben
Copy link

followben commented Aug 1, 2020

I need to setup a VPC Interface Endpoint for SES as described at https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-set-up-vpc-endpoints.html via the CDK.

Use Case

We configure and deploy our entire infrastructure as code via the javascript CDK. While I can grant our VPC access to services such as Secrets Manager using addInterfaceEndpoint() and InterfaceVpcEndpointAwsService.SECRETS_MANAGER, I can't see a way to connect SES.

Indeed, while the VPC user guide lists SES as an available interface endpoint, the same option is missing in the latest CDK.

Proposed Solution

Add the ability to setup a VPC endpoint for SES.


This is a 🚀 Feature Request

@followben followben added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 1, 2020
@SomayaB SomayaB changed the title Add VPC Endpoint for SES [ses] Add VPC Endpoint for SES Aug 3, 2020
@github-actions github-actions bot added the @aws-cdk/aws-ses Related to Amazon Simple Email Service label Aug 3, 2020
@iliapolo
Copy link
Contributor

iliapolo commented Aug 4, 2020

Hi @followben - You are correct that the SES endpoint is not available as a static member, like many others are.

However, you can still initialize the InterfaceVpcEndpointAwsService on your own and provide the service name. In your case, this would be:

new InterfaceVpcEndpointAwsService('email-smtp');

Im going to mark this as a feature request anyway to add it to our list, but you should be able to workaround this.

Let us know if this resolved your issue?

Thanks!

@iliapolo iliapolo added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Aug 4, 2020
@followben
Copy link
Author

Thanks @iliapolo - unfortunately not.

I attached an 'email-smtp' ENI endpoint to the VPC with a security group:

const vpc = new Vpc(...);
const sesVpcEndpointSecurityGroup = new SecurityGroup(
	this,
	`my-ses-vpc-security-group`,
	{
		description: `My SES VPC endpoint security group`,
		vpc,
	}
);
vpc.addInterfaceEndpoint(`my-ses-access`, {
	service: new InterfaceVpcEndpointAwsService('email-smtp'),
	securityGroups: [sesVpcEndpointSecurityGroup],
});

And granted the lambda access to that security group:

const myLambda = new Function(construct, 'my-function', {
	vpc,
	...
});
myLambda.connections.allowTo(sesVpcEndpointSecurityGroup, Port.allTcp());

Upon deployment, the vpc, security group and lambda all look to be configured as requested via the console.

I know the function works and can invoke ses.sendRawEmail() successfully when running outside the VPC (using verified addresses etc.).

However it simply hangs/ times out when running under the above configuration. I can't see any relevant logs in Cloud Formation or associated failure metrics in SES.

Do you have any further suggestions as to how I can debug and resolve?

@followben
Copy link
Author

followben commented Aug 10, 2020

Perhaps the problem is that the aws-sdk uses the service endpoint email.eu-west-1.amazonaws.com rather than the SMTP endpoint email-smtp.eu-west-1.amazonaws.com? If I alter my function send the email via SMTPS directly, the configuration appears to work.

@iliapolo
Copy link
Contributor

@followben Could you also paste the code inside the lambda you use? And also the exact the VPC configuration you use, i'd like to try and reproduce the deployment.

@ghost
Copy link

ghost commented Sep 29, 2020

I'm having the same problem. I want to send email from a lambda in a VPC.
The AWS.SES class uses HTTPS (email.eu-west-1.amazonaws.com).
The only email endpoint is that can be added to a VPC is "com.amazonaws.eu-west-1.email-smtp".

@ghost
Copy link

ghost commented Oct 1, 2020

Work-around using nodemailer and the SMTP endpoint.
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-using-smtp.html

@iliapolo iliapolo removed their assignment Jun 27, 2021
@FaresKi
Copy link

FaresKi commented Mar 22, 2022

Any news on this topic, CDK-wise?

@watany-dev
Copy link
Contributor

watany-dev commented Jan 26, 2023

This has been fixed in the latest version since I solved it

public static readonly SES = new InterfaceVpcEndpointAwsService('email-smtp');

@rantoniuk
Copy link

rantoniuk commented Feb 21, 2024

Why is the EMAIL_SMTP used instead of the SES official service name just like with all the other AWS Interface Endpoints? that's confusing..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ses Related to Amazon Simple Email Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

5 participants