-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-request.js
More file actions
32 lines (25 loc) · 853 Bytes
/
Copy pathmake-request.js
File metadata and controls
32 lines (25 loc) · 853 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
const { publishToSns } = require("./lib/sns");
const { getAndValidateParameters } = require("./lib/make-request/options");
const { testUrl } = require("./lib/make-request/test-url");
module.exports.makeRequest = async (event, context, callback) => {
let options;
try {
options = getAndValidateParameters(event, context);
} catch (error) {
console.log(JSON.stringify(event, null, 4));
console.log(JSON.stringify(context, null, 4));
return callback(error);
}
const {
homeRegion,
region,
snsTopicArn,
} = options;
const result = await testUrl(options);
try {
await publishToSns(snsTopicArn, "site-monitor-result", result, region !== homeRegion ? homeRegion : undefined);
} catch (err) {
return callback(err);
}
return callback();
};