简体   繁体   中英

AWS Lambda: SES function Task timed out

Here I'm trying to send SES mail. I'm getting the following error.

Error

Task timed out after 30.00 seconds

Code

exports.handler = (event, context, callback) => {
    function sendMail() {
        var params = { 
            Destination: {
                ToAddress: ["example@gmail.com"] 
            }, 
            Message: { 
                Body: { 
                    Text: { 
                        Data: "Test" 
                    } 
                }, 
                Subject: { 
                    Data: "Test Email" 
                } 
           }, 
           Source: "example@gmail.com" 
       }; 

        ses.sendEmail(params, function (err, data) { 
            if (err) { 
                console.log(err); 
            } else { 
                console.log(data);     
            } 
        });
    }
}

Where should I call sendMail()

I found the solution, I am using the Lambda function within VPC, where I've attached One Public Subnet and One Private Subnet. So I changed and attached Two private subnets with NAT from different AZ's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM