forked from jeffnoehren/spotinst-function-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
26 lines (23 loc) · 748 Bytes
/
handler.js
File metadata and controls
26 lines (23 loc) · 748 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
const rp = require('request-promise')
module.exports.main = function main (event, context, callback) {
let account = process.env['spotAccount']
let token = process.env['spotToken']
let environment = process.env['spotEnvironment']
let options = {
uri:'https://api.spotinst.io/functions/pattern',
method:'GET',
qs:{accountId:account,
environmentId: environment},
headers:{
"Content-Type": "application/json",
"Authorization": "Bearer " + token},
json:true
}
rp(options).then((res)=>{
console.log(res['response']['items'])
callback(null, {statusCode: 200, body: "Success"});
}).catch((err)=>{
console.log(err)
callback(null, {statusCode: 400, body: "Error Check Logs"});
})
};