Code coverage report for autoScaling/doesLaunchConfigurationExist.js

Statements: 100% (5 / 5)      Branches: 100% (0 / 0)      Functions: 100% (2 / 2)      Lines: 100% (5 / 5)      Ignored: none     

All files » autoScaling/ » doesLaunchConfigurationExist.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    1                         1 2         2       1  
'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