title: return value from lambda function
body: <pre><code>const AWS = require('aws-sdk');
  
  exports.handler = (event) =&gt; {
      AWS.config.update({region: 'eu-west-1'});
      var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'});
  
      var alarmStatus = {};
      cw.describeAlarms({}, function(err, data) {
          if (err) {
              console.log("Error", err);
          } else {
              data.MetricAlarms.forEach(function (item, index, array) {
                  var pair = {[item.AlarmName]: item.StateValue};
                  alarmStatus = {...alarmStatus, ...pair};
                  console.log(alarmStatus);
              });
          }
      });
  
      const response = {
          statusCode: 200,
          body: JSON.stringify(alarmStatus),
      };
      return response;
  };
  </code></pre>
  
  <p>I want to send response back to the caller of the lambda function, but since describe alarm function of cloudwatch is asynchronous, I am getting empty response in the body. How can I wait for the function to execute before returning the response?</p>