I have a simple AWS Lambda function that sends an email using nodemailer. The provider is 'Gmail' with:
SMTP_SECURE: true,
SMTP_PORT: 465
The problem is the API gateway URL times out after 30456.58 ms with 504 Gateway Timeout. It's clearly mentioned in AWS documentation that it will timeout after the 30s and that is acceptable too.
The same thing happens when I directly invoke lambda from the AWS lambda console. It times out too. The thing which is not making a sense to me it
transporter.sendMail(mailOptions);
why these lines take more than 30 seconds? and also when API gateway timeout lambda also timeout. I have already attached VPC, subnet, and security having traffic from all and also enable less secure on google.
Cloudwatch logs clearly indicate that my code is not going beyond:
const info = await transporter.sendMail(mailOptions);
PS: Everything works like a charm on my local machine, the problem is only in the cloud function.
here are the security outgoings:
Security group outbound rules:
Lambda function outbound rules:

