repo_description: Deploy Node.js projects to AWS Lambda and API Gateway easily
repo_topics: api-gateway aws aws-lambda claudia javascript nodejs serverless
code: const retry = require('oh-no-i-insist');
  module.exports = function waitUntilNotPending(lambda, functionName, timeout, retries) {
  	'use strict';
  	return retry(
  		() => {
  			return lambda.getFunctionConfiguration({FunctionName: functionName}).promise()
  				.then(result => {
  					if (result.state === 'Failed') {
  						throw `Lambda resource update failed`;
  					}
  					if (result.state === 'Pending') {
  						throw 'Pending';
  					}
  					if (result.LastUpdateStatus === 'InProgress') {
  						throw 'Pending';
  					}
  				});
  		},
  		timeout,
  		retries,
  		failure => failure === 'Pending',
  		() => console.log('Lambda function is in Pending state, waiting...'),
  		Promise
  	);
  };
  
  
  