I've written an AWS lambda that makes an https request to an endpoint that triggers a reset password email. When I run my lambda locally, all runs as expected and I get the email in my inbox, however, when I upload my node code and run the lambda in the AWS console, I get the following error at the point of making the post request:
Error: getaddrinfo ENOTFOUND myfakedomain.com myfakedomain.com:443
The function in my lambda making the https request (using the superagent node module) looks like the following:
function resetPassword(intentRequest, callback) {
const emailAddress = intentRequest.currentIntent.slots.EmailAddress;
console.log(`emailAddress is: ${emailAddress}`);
request
.post('https://myfakedomain.com:443/passwordreset', emailAddress)
.set({ 'Content-Type': 'text/plain' })
.end((resp) => {
console.log('response was: ' + resp);
});
callback(close(intentRequest.sessionAttributes, 'Fulfilled',
{ contentType: 'PlainText', content: `Thanks, a reset password link has been sent to ${emailAddress}.` }));
}
Is there any particular reason for this error when running my lambda via AWS? The reset password endpoint is open so that anyone is able to hit it. I've also tried removing the https:// from the beginning of my post request, but no luck. I guess it doesn't help the error logging is pretty minimal too!
Any help would be great, thanks.