title: AWS Lambda response in Java for Cognito
body: <p>How can I write an "AWS Lambda response" in Java so that Cognito is happy?</p>
  
  <p>Something like this is passed to the lambda function</p>
  
  <pre><code>{
  "version": number,
  "triggerSource": "string",
  "region": AWSRegion,
  "userPoolId": "string",
  "callerContext": 
      {
          "awsSdkVersion": "string",
          "clientId": "string"
      },
  "request":
      {
          "userAttributes": {
              "string": "string",
              ....
          }
      },
  "response": {}
  }
  </code></pre>
  
  <p>Now I need to make the response in Java.. and send back to Cognito. At the moment Cognito throws an <strong>"InvalidLambdaResponseException".</strong></p>
  
  <p>Java code below just returns the event.. </p>
  
  <pre><code>public class LambdaFunctionHandler implements RequestHandler&lt;CognitoEvent, CognitoEvent&gt; 
  {
      @Override
      public CognitoEvent handleRequest(CognitoEvent arg0, Context arg1) 
      {
          return arg0;
      }
  }
  </code></pre>