title: Amazon AWS Cognito Lambda Triggers Not Working With Simple PHP BREF Function
body: <p>I recently started experimenting with using the bref (<a href="https://bref.sh/docs/" rel="nofollow noreferrer">https://bref.sh/docs/</a>) package to use PHP for Lambda functions on Amazon AWS. I'm able to use this package perfectly fine to upload a simple Lambda function, as simple as it can get:</p>
  
  <pre><code>&lt;?php
  
  require __DIR__.'/vendor/autoload.php';
  
  lambda(function ($event) {
      return $event;
  });
  </code></pre>
  
  <p>Then I take this Lambda function and start assigning it to Cognito triggers. It works great for the Pre sign-up trigger, no issues at all hitting it when I create a new account from the admin panel in Cognito.</p>
  
  <p>However when I take this same exact trigger and add it to the Pre-authentication Cognito trigger, then test it with a simple Symfony app I have running locally to act as a simple authentication mechanism using Cognito (developed using this tutorial: <a href="https://tech.mybuilder.com/managing-authentication-in-your-symfony-project-with-aws-cognito/" rel="nofollow noreferrer">https://tech.mybuilder.com/managing-authentication-in-your-symfony-project-with-aws-cognito/</a>), it immediately returns the error: </p>
  
  <pre><code>Error executing "AdminInitiateAuth" on "https://cognito-idp.us-east-2.amazonaws.com"; AWS HTTP error: Client error: `POST https://cognito-idp.us-east-2.amazonaws.com` resulted in a `400 Bad Request` response:
  {"__type":"InvalidLambdaResponseException","message":"Unrecognizable lambda output"}
  InvalidLambdaResponseException (client): Unrecognizable lambda output - {"__type":"InvalidLambdaResponseException","message":"Unrecognizable lambda output"}
  </code></pre>
  
  <p>When I disable the above lambda it immediately starts working without error, so the issue is not with my Symfony app, it's somehow with the lambda (even though it's just returning the event that it is given and works for other triggers, as noted above).</p>
  
  <p>Even when I replace this with a simple lambda that is basically the equivalent in Node, it works fine:</p>
  
  <pre><code>exports.handler = async (event) =&gt; {
      return event;
  };
  </code></pre>
  
  <p>Does anyone have any idea why the PHP lambda doesn't seem to be working with the Cognito Pre-authentication trigger? I would prefer to do this in PHP if possible.</p>