title: How to use AWS.CloudFront.Signer in Lambda function
body: <p>I'm trying to use Lambda to generate and return a signed cookie so my iOS app can use the cookie to access restricted files via CloudFront.</p>
  
  <p>I think this should be possible using the Signer class: <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront/Signer.html" rel="noreferrer">http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront/Signer.html</a></p>
  
  <p>On this basis I have written the following Lambda function:</p>
  
  <pre><code>var AWS = require('aws-sdk');
  var keyPairId = 'APK...';
  var privateKey = 'MIIE...';
  var signer = new AWS.CloudFront.Signer(keyPairId, privateKey);
  
  exports.handler = function(event, context) {
      var options = {url: "https://xxxxxx.cloudfront.net", expires: 1357100000};
  
      signer.getSignedCookie(options, function(err, data) {
          if (err) {
              context.fail(err);
          } else {
              context.succeed('Success');
          }
      });
  };
  </code></pre>
  
  <p>However, this does not work. I keep getting the error 'Process exited before completing request'. I have tried many permutations for the format of the 'options' parameter, none of which make any difference.</p>
  
  <p>Any help would be appreciated.</p>