title: Adding Data to Amazon RDS through Lambda Function
body: <p>I've been trying to create an Alexa skill which is written in nodejs and I wanted to push some data through to an RDS database. I've configured the VPC and security groups which should mean the lambda function has access to the database, as I'm new to writing code in node I think I may have incorrectly written my query function. I have the node-mysql module in my zip file for the lambda function so there are no issues with that. </p>
  
  <pre><code>var mysql      = require('mysql');
  
    var connection = mysql.createConnection({
      host     :  rds endpoint,
      user     : 'mohammad',
      password : 'password',
      database : 'motivate'
    });
  
    connection.connect(function(err){
      if (err) {
        console.error('error connecting: ' + err.stack);
        return;
      }
      console.log('connected as id ' + connection.threadId);
    });
  
    for(var i = 0; i &lt; authors.length; i++){
      var postData = {author: authors[i], quote: quotes[i]};
  
      var query = connection.query('INSERT INTO quotes SET ?', postData, function(err, result) {
        console.log(err);
      });
      console.log(query.sql);
    }
  
    connection.end();
  </code></pre>
  
  <p>This is all within my exports.handler except for the require('mysql') which is at the very beginning of the code. I assume the code runs successfully as there are no errors and the console prints as follows.</p>
  
  <pre><code>2017-01-11T00:20:47.141Z    c41a492d-d793-11e6-8344-27807a741276    INSERT INTO quotes SET `author` = 'Theodore Roosevelt', `quote` = 'Keep your eyes on the     stars, and your feet on the ground.'
  2017-01-11T00:20:47.141Z    c41a492d-d793-11e6-8344-27807a741276    INSERT INTO quotes SET `author` = 'Nelson Mandela', `quote` = 'It always seems impossible until it\'s done.'
  2017-01-11T00:20:47.141Z    c41a492d-d793-11e6-8344-27807a741276    INSERT INTO quotes SET `author` = 'Og Mandino', `quote` = 'Failure will never overtake me if my determination to succeed is strong enough.' 
  2017-01-11T00:20:47.199Z    c41a492d-d793-11e6-8344-27807a741276    New Session
  2017-01-11T00:20:47.199Z    c41a492d-d793-11e6-8344-27807a741276    Launch Request
  REPORT RequestId: c41a492d-d793-11e6-8344-27807a741276  Duration: 925.98 ms Billed Duration: 1000 ms    Memory Size: 128 MB Max Memory Used: 21 MB  
  </code></pre>
  
  <p>One thing I've noticed is that the console.log('connected as id ' + connection.threadId); is not being executed as there is nothing in the log. I'm unsure if I've improperly set my connection up in the createConnection portion or if the error is coming from another portion of my code.</p>