'use strict'
var _ = require('lodash')
/**
* Uses AutoScaling.describeAutoScalingGroups to check existence of the
* auto scaling group. If the list of AutoScalingGroups returned is empty
* doesAutoScalingGroupExist is resolved as False, if it's not empty it is
* resolved as True.
*
* @param autoScaling
* @param asgName
*
* @returns {Promise}
*/
function doesAutoScalingGroupExist (autoScaling, asgName) {
return autoScaling
.describeAutoScalingGroupsPromised({
AutoScalingGroupNames: [ asgName ]
})
.then(function found (data) {
return !_.isEmpty(data.AutoScalingGroups)
})
}
module.exports = doesAutoScalingGroupExist
|