title: AWS Lambda publishing to IOT Topic fires indefinitely
body: <p><strong>The Issue:</strong></p>
  
  <p>I have a node.js (8.10) AWS Lambda function that takes a json object and publishes it to an IOT topic. The function successfully publishes to the topic, however, once fired it is continuously called until I throttle the concurrency to zero to halt any further calling of the function.</p>
  
  <p>I'm trying to figure out what I've implemented incorrectly that causes more than one instance the of the function to be called.</p>
  
  <p><strong>The Function:</strong></p>
  
  <p>Here is my function:</p>
  
  <pre><code>var AWS = require('aws-sdk');
  
  exports.handler = function (event, context) {
      var iotdata = new AWS.IotData({endpoint: 'xxxxxxxxxx.iot.us-east-1.amazonaws.com'});
      var params = {
          topic: '/PiDevTest/SyncDevice',
          payload: JSON.stringify(event),
          qos: 0
      };
  
      iotdata.publish(params, function(err, data) {
          if (err) {
            console.log(err, err.stack);
          } else {
              console.log("Message sent.");
              context.succeed();
          }     
      });
  };
  </code></pre>
  
  <p>My test json is:</p>
  
  <pre><code>{
    "success": 1,
    "TccvID": "TestID01"
  }
  </code></pre>
  
  <p>The test console has a response of "null", but the IOT topic shows the data from the test json, published to the topic about once per second.</p>
  
  <p><strong>What I've Tried</strong></p>
  
  <p>-I've attempted to define the handler in it's own, non-anonymous function called handler, and then having the exports.handler = handler; This didn't produce any errors, but didn't successfully post to the iot topic either.</p>
  
  <p>-I thought maybe the issues was with the node.js callback. I've tried implementing it and leaving it out (Current iteration above), but neither way seemed to make a difference. I had read somewhere that the function will retry if  it errors, but I believe that only happens three times so it wouldn't explain the indefinite calling of the function.</p>
  
  <p>-I've also tried calling the function from another lambda to make sure that the issue wasn't the aws test tool. This produced the same behavior, though.</p>
  
  <p><strong>Summary:</strong></p>
  
  <p>What am I doing incorrectly that causes this function to publish the json data indefinitely to the iot topic?</p>
  
  <p>Thanks in advance for your time and expertise. </p>