UpdateItem in AWS DynamoDB using AWS Lambda (node)
<p>I'm trying to update a record in DynamoDB using Lambda (node). I can change the structure of <code>params</code> and get errors like <code>Expected params.ExpressionAttributeValues[':done'] to be a structure</code>, so I believe it's communicating with DynamoDB.</p>

<p>This is the params:</p>

<pre><code>{
  "TableName": "test_table",
  "Key": {
      "id": {
          "S": "90c31f23-96e3-4d5d-b08d-95aafb9bed2e"
      }
  },
  "UpdateExpression": "SET done = :done",
  "ExpressionAttributeValues": {
      ":done": {
          "S": "t"
      }
  },
  "ReturnValues": "UPDATED_NEW"
}
</code></pre>

<p>From there it just times out, so it's hard to know what the issue is.</p>

<p>This is the full lambda function:</p>

<pre><code>var aws = require('aws-sdk');
var dynamodb = new aws.DynamoDB({
  apiVersion: '2012-08-10',
  accessKeyId: 'xxx',
  secretAccesskey: 'xxx',
  region: 'us-west-2'
})

exports.handler = (event, context, callback) =&gt; {
    console.log('Incoming: ', event);

    var table = "test_table";

    event.Records.forEach((record) =&gt; {
      console.log('DynamoDB Record: %j', record.dynamodb);

      var params = {
        TableName: table,
        Key: {
          "id": record.dynamodb.Keys.id
        },
        UpdateExpression: "SET done = :done",
        ExpressionAttributeValues: {
          ":done": { "S": "t" }
        },
        ReturnValues: "UPDATED_NEW"
      };

      console.log("params: %j", params);

      dynamodb.updateItem(params, function(err, data) {
        if (err) console.log("Unable to update item. Error: ", JSON.stringify(err, null, 2));
        else console.log("Updated item succeeded: ", JSON.stringify(data, null, 2));
      });
    });
    callback(null, "Successfully processed ${event.Records.length} records.");
};
</code></pre>