-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (38 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var aws = require('aws-sdk');
var ses = new aws.SES({
region: 'us-east-1'
});
exports.handler = function(event, context) {
console.log("Incoming: ", event);
// var output = querystring.parse(event);
var SnsMessage = event.Records[0].Sns.Message;
var url = event.Records[0].Sns.Subject;
console.log(event.Records[0].Sns.Message);
var eParams = {
Destination: {
ToAddresses: [JSON.parse(event.Records[0].Sns.Message)]
},
Message: {
Body: {
Text: {
Data: url
}
},
Subject: {
Data: “Reset password”
}
},
Source: “[email protected]"
};
console.log('===SENDING EMAIL===');
var email = ses.sendEmail(eParams, function(err, data){
if(err) console.log(err);
else {
console.log("===EMAIL SENT===");
console.log(data);
console.log("EMAIL CODE END");
console.log('EMAIL: ', email);
context.succeed(event);
}
});
}