forked from Ashwin1234/CS441-CourseProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.js
More file actions
41 lines (32 loc) · 1015 Bytes
/
Copy pathlambda.js
File metadata and controls
41 lines (32 loc) · 1015 Bytes
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
const https = require('https');
const doPostRequest = (key) => {
const data = {"appId": "6450ec5c-551e-11ec-bf63-0242ac130002", "key":${key}};
return new Promise((resolve, reject) => {
const options = {
host: 'ec2-44-200-16-152.compute-1.amazonaws.com',
path: '',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
//create the request object with the callback with the result
const req = https.request(options, (res) => {
resolve(JSON.stringify(res.statusCode));
});
// handle the possible errors
req.on('error', (e) => {
reject(e.message);
});
//do the request
req.write(data);
//finish the request
req.end();
});
};
exports.handler = async (event) => {
console.log(event.Records.s3)
await doPostRequest(event)
.then(result => console.log(Status code: ${result}))
.catch(err => console.error(Error doing the request for the event: ${JSON.stringify(event)} => ${err}));
};