Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK Update + Validate Service Exists #2111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions collectors/aws/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
- api_calls: (Optional) If provided, will only query these APIs.
- Example:
{
"skip_regions": ["us-east-2", "eu-west-1"],
"api_calls": ["EC2:describeInstances", "S3:listBuckets"]
"skip_regions": ["us-east-2", "eu-west-1"],
"api_calls": ["EC2:describeInstances", "S3:listBuckets"]
}
- callback: Function to call when the collection is complete
*********************/
Expand Down Expand Up @@ -84,6 +84,9 @@ var collect = function(AWSConfig, settings, callback) {
var serviceLower = service.toLowerCase();
if (!collection[serviceLower]) collection[serviceLower] = {};

// Log service being processed
console.log(`[INFO] Processing service: ${serviceName}`);

// Loop through each of the service's functions
async.eachOfLimit(call, 15, function(callObj, callKey, callCb) {
if (settings.api_calls && settings.api_calls.indexOf(serviceName + ':' + callKey) === -1) return callCb();
Expand Down Expand Up @@ -136,6 +139,11 @@ var collect = function(AWSConfig, settings, callback) {
}
});
} else {
if (!AWS[serviceName]) {
console.error(`[ERROR] Service ${serviceName} does not exist in AWS SDK.`);
regionCb();
return;
}
var executor = debugMode ? (AWSXRay.captureAWSClient(new AWS[serviceName](LocalAWSConfig))) : new AWS[serviceName](LocalAWSConfig);
var paginating = false;
var executorCb = function(err, data) {
Expand Down Expand Up @@ -244,6 +252,9 @@ var collect = function(AWSConfig, settings, callback) {

if (!collection[serviceLower]) collection[serviceLower] = {};

// Log service being processed
console.log(`[INFO] Processing postcall for service: ${serviceName}`);

async.eachOfLimit(serviceObj, 1, function(callObj, callKey, callCb) {
if (settings.api_calls && settings.api_calls.indexOf(serviceName + ':' + callKey) === -1) return callCb();

Expand Down Expand Up @@ -278,10 +289,10 @@ var collect = function(AWSConfig, settings, callback) {

if (callObj.reliesOnCall &&
(!collection[callObj.reliesOnService] ||
!collection[callObj.reliesOnService][callObj.reliesOnCall] ||
!collection[callObj.reliesOnService][callObj.reliesOnCall][region] ||
!collection[callObj.reliesOnService][callObj.reliesOnCall][region].data ||
!collection[callObj.reliesOnService][callObj.reliesOnCall][region].data.length))
!collection[callObj.reliesOnService][callObj.reliesOnCall] ||
!collection[callObj.reliesOnService][callObj.reliesOnCall][region] ||
!collection[callObj.reliesOnService][callObj.reliesOnCall][region].data ||
!collection[callObj.reliesOnService][callObj.reliesOnCall][region].data.length))
return regionCb();

var LocalAWSConfig = JSON.parse(JSON.stringify(AWSConfig));
Expand All @@ -305,6 +316,11 @@ var collect = function(AWSConfig, settings, callback) {
}
});
} else {
if (!AWS[serviceName]) {
console.error(`[ERROR] Service ${serviceName} does not exist in AWS SDK.`);
regionCb();
return;
}
var executor = debugMode ? (AWSXRay.captureAWSClient(new AWS[serviceName](LocalAWSConfig))) : new AWS[serviceName](LocalAWSConfig);

if (!collection[callObj.reliesOnService][callObj.reliesOnCall][LocalAWSConfig.region] ||
Expand Down Expand Up @@ -424,4 +440,4 @@ var collect = function(AWSConfig, settings, callback) {
});
};

module.exports = collect;
module.exports = collect;
16 changes: 16 additions & 0 deletions collectors/aws/collector_multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ var collect = function(AWSConfig, settings, callback) {
var serviceLower = service.toLowerCase();
if (!collection[serviceLower]) collection[serviceLower] = {};

// Log service being processed
console.log(`[INFO] Processing service: ${serviceName}`);

// Loop through each of the service's functions
async.eachOfLimit(call, 15, function(callObj, callKey, callCb) {
if (settings.api_calls && settings.api_calls.indexOf(serviceName + ':' + callKey) === -1) return callCb();
Expand Down Expand Up @@ -165,6 +168,11 @@ var collect = function(AWSConfig, settings, callback) {
}
});
} else {
if (!AWS[serviceName]) {
console.error(`[ERROR] Service ${serviceName} does not exist in AWS SDK.`);
regionCb();
return;
}
var executor = debugMode ? (AWSXRay.captureAWSClient(new AWS[serviceName](LocalAWSConfig))) : new AWS[serviceName](LocalAWSConfig);
var paginating = false;
var executorCb = function(err, data) {
Expand Down Expand Up @@ -284,6 +292,9 @@ var collect = function(AWSConfig, settings, callback) {

if (!collection[serviceLower]) collection[serviceLower] = {};

// Log service being processed
console.log(`[INFO] Processing service: ${serviceName}`);

async.eachOfLimit(serviceObj, 1, function(callObj, callKey, callCb) {
if (settings.api_calls && settings.api_calls.indexOf(serviceName + ':' + callKey) === -1) return callCb();

Expand Down Expand Up @@ -345,6 +356,11 @@ var collect = function(AWSConfig, settings, callback) {
}
});
} else {
if (!AWS[serviceName]) {
console.error(`[ERROR] Service ${serviceName} does not exist in AWS SDK.`);
regionCb();
return;
}
var executor = debugMode ? (AWSXRay.captureAWSClient(new AWS[serviceName](LocalAWSConfig))) : new AWS[serviceName](LocalAWSConfig);

if (!collection[callObj.reliesOnService][callObj.reliesOnCall][LocalAWSConfig.region] ||
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
"dependencies": {
"@alicloud/pop-core": "^1.7.10",
"@azure/data-tables": "^13.2.2",
"@azure/storage-blob": "^12.14.0",
"@azure/storage-file-share": "^12.14.0",
"@azure/storage-queue": "^12.13.0",
"@azure/storage-blob": "^12.14.0",
"@octokit/auth-app": "^6.0.3",
"@octokit/request": "^8.1.6",
"@octokit/rest": "^20.0.2",
"ali-oss": "^6.15.2",
"argparse": "^2.0.0",
"async": "^2.6.1",
"aws-sdk": "^2.1506.0",
"aws-sdk": "^2.1692.0",
"azure-storage": "^2.10.3",
"csv-write-stream": "^2.0.0",
"fast-safe-stringify": "^2.0.6",
Expand Down
Loading