'use strict'
var _ = require('lodash')
/**
* Uses AutoScaling.describeLaunchConfigurations to check existence of the
* launch configuration. If the list of LaunchConfigurations returned is empty
* doesLaunchConfigurationExist is resolved as False, if it's not empty it is
* resolved as True.
*
* @param autoScaling
* @param launchConfigurationName
*
* @returns {Promise}
*/
function doesLaunchConfigurationExist (autoScaling, launchConfigurationName) {
return autoScaling.
describeLaunchConfigurationsPromised({
LaunchConfigurationNames: [ launchConfigurationName ]
})
.then(function found (data) {
return !_.isEmpty(data.LaunchConfigurations)
})
}
module.exports = doesLaunchConfigurationExist
|