title: Lambda@edge function using python
body: <p>We are trying to write a lambda@edge function to trigger on <code>viewer-request</code>. I was able to find lots of examples on using JavaScript.</p>
  
  <p>e.g</p>
  
  <pre><code>'use strict';
  
  exports.handler = (event, context, callback) =&gt; {
      console.log('Event: ', JSON.stringify(event, null, 2));
      console.log('Context: ', JSON.stringify(context, null, 2));
      const request = event.Records[0].cf.request;
  
      // You can also store and read the redirect map
      // in DynamoDB or S3, for example.
      const redirects = {
          '/r/music':    '/card/bcbd2481',
          '/r/tree':     '/card/da8398f4',
      };
  
      if (redirects[request.uri]) {
          return callback(null, {
              status: '302',
              statusDescription: 'Found',
              headers: {
                  'location': [{ 
                      key: 'Location',
                      value: redirects[request.uri] }]
              }
          });
      }
  
      callback(null, request);
  };
  </code></pre>
  
  <p>The above code will redirect requests that matches a specific path. Can anyone advice on how to port a similiar code to python? or share resources/information on deploying python lambda@edge functions.</p>
  
  <p>Thanks</p>