-
Notifications
You must be signed in to change notification settings - Fork 5
/
extract.js
41 lines (37 loc) · 873 Bytes
/
extract.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
'use strict';
var Promise = require('bluebird');
var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
var ec2 = new AWS.EC2({});
var params = {
Filters: [
{
Name: 'group-name',
Values: [
'*AppName*'
]
}
]
}
var extractPromise = function () {
// console.log('Getting security groups');
var promise = new Promise(function (resolve, reject) {
ec2.describeSecurityGroups(params, function (err, data) {
// console.log('Got security groups');
if (err) {
// console.log(err, err.stack);
reject(err);
} else {
resolve(data);
}
});
});
return promise;
}
module.exports = extractPromise;
// Output to console if called directly.
if (require.main === module) {
module.exports().then(function (data) {
console.log(JSON.stringify(data, null, 2));
});
}