async.eachLimit(helpers.regions[serviceLower], helpers.MAX_REGIONS_AT_A_TIME, function(region, regionCb){ if (settings.skip_regions && settings.skip_regions.indexOf(region) > -1 && globalServices.indexOf(service) === -1) return regionCb(); if (!collection[serviceLower][callKey][region]) collection[serviceLower][callKey][region] = {}; var LocalAWSConfig = JSON.parse(JSON.stringify(AWSConfig)); LocalAWSConfig.region = region; if (callObj.override) { collectors[serviceLower][callKey](LocalAWSConfig, collection, function(){ if (callObj.rateLimit) { setTimeout(function(){ regionCb(); }, callObj.rateLimit); } else { regionCb(); } }); } else { var executor = new AWS[service](LocalAWSConfig); var executorCb = function(err, data){ if (err) { collection[serviceLower][callKey][region].err = err; } // TODO: pagination // TODO: handle s3 region fixes (possibly use an override) if (!data) return regionCb(); if (callObj.property && !data[callObj.property]) return regionCb(); if (callObj.secondProperty && !data[callObj.secondProperty]) return regionCb(); if (callObj.secondProperty) { collection[serviceLower][callKey][region].data = data[callObj.property][callObj.secondProperty]; } else { collection[serviceLower][callKey][region].data = data[callObj.property]; } if (callObj.rateLimit) { setTimeout(function(){ regionCb(); }, callObj.rateLimit); } else { regionCb(); } }; if (callObj.params) { executor[callKey](callObj.params, executorCb); } else { executor[callKey](executorCb); } } }, function(){
async.eachLimit(helpers.regions[serviceLower], helpers.MAX_REGIONS_AT_A_TIME, function(region, regionCb){ if (settings.skip_regions && settings.skip_regions.indexOf(region) > -1 && globalServices.indexOf(service) === -1) return regionCb(); if (!collection[serviceLower][callKey][region]) collection[serviceLower][callKey][region] = {}; // Ensure pre-requisites are met if (callObj.reliesOnService && !collection[callObj.reliesOnService]) return regionCb(); 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)) return regionCb(); var LocalAWSConfig = JSON.parse(JSON.stringify(AWSConfig)); if (callObj.deleteRegion) { //delete LocalAWSConfig.region; LocalAWSConfig.region = 'us-east-1'; } else { LocalAWSConfig.region = region; } if (callObj.signatureVersion) LocalAWSConfig.signatureVersion = callObj.signatureVersion; if (callObj.override) { collectors[serviceLower][callKey](LocalAWSConfig, collection, function(){ if (callObj.rateLimit) { setTimeout(function(){ regionCb(); }, callObj.rateLimit); } else { regionCb(); } }); } else { var executor = new AWS[service](LocalAWSConfig); if (!collection[callObj.reliesOnService][callObj.reliesOnCall][LocalAWSConfig.region] || !collection[callObj.reliesOnService][callObj.reliesOnCall][LocalAWSConfig.region].data) { return regionCb(); } async.eachLimit(collection[callObj.reliesOnService][callObj.reliesOnCall][LocalAWSConfig.region].data, 10, function(dep, depCb){ collection[serviceLower][callKey][LocalAWSConfig.region][dep[callObj.filterValue]] = {}; var filter = {}; filter[callObj.filterKey] = dep[callObj.filterValue]; executor[callKey](filter, function(err, data){ if (err) { collection[serviceLower][callKey][LocalAWSConfig.region][dep[callObj.filterValue]].err = err; depCb(); } else { collection[serviceLower][callKey][LocalAWSConfig.region][dep[callObj.filterValue]].data = data; depCb(); } }); }, function(){ if (callObj.rateLimit) { setTimeout(function(){ regionCb(); }, callObj.rateLimit); } else { regionCb(); } }); } }, function(){