title: Lambda@Edge not setting cookies in response
body: <p>I am doing something probably unusual and ill-advised to <a href="https://stackoverflow.com/questions/55128624/cloudfront-lambdaedge-set-cookie-on-viewer-request">overcome a limitation with request and response behavior</a>. </p>
  
  <p>I am having an Origin Request Lambda call back to the initial URL via <code>https.get</code>, with a parameter passed in the header. This will cause a secondary behavior for the same URL request, allowing me to mutate the response in the original Origin Request Lambda before returning a custom response. </p>
  
  <p>The long version:</p>
  
  <ol>
  <li><p>Function 1 of <strong>Viewer Request Lambda</strong> fires when there <em>is not</em> the custom property <code>my-uuid</code> in the header. It will create the UUID, set that UUID in the <code>my-uuid</code> property on the header, and then fire the callback with the updated header. </p></li>
  <li><p>Function 1 of the <strong>Origin Request Lambda</strong> fires where <code>my-uuid</code> header <em>is</em> present. Cloudfront is configured to cache based on this header alone, so that the generated UUID will always trigger Function 1 of the Origin Request Lambda. Function 1 makes an <code>https.get</code> call to the URL called in the original request, but passed along the <code>my-uuid</code> header. </p></li>
  <li><p>Function 2 of the <strong>Viewer Request Lambda</strong> fires based on the presence of the <code>my-uuid</code> header in this second run. This simply strips the <code>my-uuid</code> header and fires the callback sans <code>my-uuid</code> header property. </p></li>
  <li><ol>
  <li><p>This page has been called before and is in the Cloudfront cache. As the request does not have the <code>my-uuid</code> header property, there is no cache-busting, and the cached page is returned to Function 1 of the <strong>Origin Request Lambda</strong>. OR:</p></li>
  <li><p>This page has not yet been cached, so Function 2 of the <strong>Origin Request Lambda</strong> is invoked. In the absence of the <code>my-uuid</code> header property, it simply fires the callback with the request as-is. </p></li>
  </ol></li>
  <li><p>Either way, Function 1 of the <strong>Origin Request Lambda</strong> receives the HTML from the <code>https.get</code> call, and uses this to create a custom response object with the body of the desired page but <em>also the set-cookie header containing the UUID I generated in the initial <strong>Viewer Request Lambda</em></strong>. This custom response object is passed into the callback.</p></li>
  </ol>
  
  <p>While on that path, the solution I crafted brought me to another issue:</p>
  
  <p>Steps 3 and 4.2 (the Function 2 of either <strong>Request Lambda</strong>) are not logging at all when I call my endpoint via Postman. I have a plethora of console logs to track what's happening internally. However, the response has any headers I try to set in the final response (except, annoyingly, the <code>set-cookie</code> header which appears to simply disappear and is why I need the logging to work).  </p>
  
  <p>If I set the <code>my-uuid</code> header on my Postman request to trigger the Function 2 behavior, I do see those in the log. </p>