title: Lambda Times Out Writing to DynamoDB
body: <p>I have a simple function that puts an item into the database.  I have enabled a role that has a policy attached to allow puts for this table.
  Here is the code below.  I have even tired hard coding all the information still it times out.  I have also tried increasing the timeout to 30 seconds and the Memory to 512 MB but it still just times out.  any help would be greatly appreciated.</p>
  <pre><code>const AWS = require(`aws-sdk`);
  AWS.config.update({region: `eu-east-2`});
  const dynamo = new AWS.DynamoDB.DocumentClient();
  
  exports.handler = function(event, context, callback){
  
     
     var TableName =&quot;MyFirstExamAnswers&quot;;
     var Item = {};
    
      Item[&quot;Student&quot;] = event.params.Student;
      Item[event.params.Question] = event.params.Answer;
      console.log(&quot;theItem: &quot;+ JSON.stringify( Item));
   
      dynamo.put({TableName,Item}, function (err, data) {
          if (err) {
              console.log(`error`, err);
              callback(err, null);
          } else {
              var response = {
                  statusCode: 200,
                  headers: {
                     'Access-Control-Allow-Methods': `GET,POST,OPTIONS`,
                     'Access-Control-Allow-Origin': `*`,
                     'Access-Control-Allow-Credentials': `true`
                 },
                  body: JSON.stringify(data),
                  isBase64Encoded: false
              };
              console.log(`success: returned ${data.Item}`);
             
             callback(null, response);
         }
      });
      
  };
  </code></pre>
  <p>With the following policy attached to the role that the Lambda is running under</p>
  <pre><code>{
      &quot;Version&quot;: &quot;2012-10-17&quot;,
      &quot;Statement&quot;: [
          {
              &quot;Sid&quot;: &quot;AllowDBAccess2Lambda001&quot;,
              &quot;Effect&quot;: &quot;Allow&quot;,
              &quot;Action&quot;: [
                  &quot;dynamodb:PutItem&quot;
              ],
              &quot;Resource&quot;: &quot;arn:aws:dynamodb:us-east-2:MyAccountNumber:table/MyFirstExamAnswers&quot;
          }
      ]
  }
  
  </code></pre>