title: Cloudfront and multiple Lambda@Edge functions
body: <p>I have a Cloudfront distribution pointing at a custom url.
  In that distribution, I have setup 2 lambda function associations.
  1 on the Cloudfront event of viewer-request to query parameter store and redirect to the correct url
  The other on the Cloudfront event of origin-response to gather response stats from the call.</p>
  <p>The viewer-reqest function is as follows - <strong>note</strong> dummy urls for purpose of question</p>
  <pre><code>exports.handler = async (event, context) =&gt; {
      const origin = &quot;main&quot;;
      const primaryUrl = &quot;https://www.google.com&quot;;
      const drUrl = &quot;https://www.yahoo.com&quot;;
  
      let url = primaryUrl;
  
      if (origin != &quot;main&quot;) {
          url = drUrl;
      } else {
          url = primaryUrl;
      }
  
      const response = {
          status: '302',
          statusDescription: 'Found',
          headers: {
              location: [{
                  key: 'Location',
                  value: url,
              }],
          },
      };
  
      return response;
  };
  </code></pre>
  <p>The origin response lambda is very simple for now
  var AWS = require('aws-sdk');
  AWS.config.update({ region: 'us-east-1' });
  var cloudwatch = new AWS.CloudWatch();</p>
  <pre><code>exports.handler = async (event, context) =&gt; {
      console.log(&quot;Custom Metrics Event&quot;);
      console.log(JSON.stringify(event));
  
      const response = {
          status: '200', 
      };
  
      return response;
  };
  </code></pre>
  <p>When I call the cloudfront distribution domain, the viewer-request lambda@edge kicks in but the origin-response lambda does not trigger and I see nothing in cloudwatch
  If I remove the viewer-request lambda - the origin-response lambda does trigger</p>
  <p>Am I doing anything wrong here or does anyone have any recommendations?</p>
  <p>Thank you
  Damien</p>