In 2020 this is now possible by creating a VPC endpoint for SES (for the security group part just enable all traffic with the source being the security group the lambda belongs to).
However, as far as I can tell you cannot send mail using the SES API, you have to use SMTP. I set up my lambda as follows:
"use strict";
const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
host: "email-smtp.YOURREGION.amazonaws.com",
port: 465,
secure: true,
auth: {
user: process.env.USER,
pass: process.env.PASS,
},
});
const SENDER = 'no-reply@domain.com';
const RECEIVER = 'to@domain.com';
const response = {
"statusCode": 200,
"headers": { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'},
"body": "{\"result\": \"Success.\"}"
};
const errResponse = {
"statusCode": 500,
"headers": {'Access-Control-Allow-Origin': '*'},
"body": "{\"result\": \"Failed.\"}"
};
exports.handler = function (event, context, callback) {
transporter.sendMail({
from: SENDER,
to: RECEIVER,
subject: "Hello ✔",
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
}, function(error, info) {
if (error) {
console.log(error);
callback(errResponse, null);
} else {
console.log('Email sent: ' + info);
callback(null, response);
}
});
};