1

my RDS mysql public database instance can be connected from mysql clients. But when i trying the same in AWS Lambda it won't work. my code is given below.

console.log('Loading function');
var doc = require('dynamodb-doc');
var dynamo = new doc.DynamoDB();
var mysql = require('mysql');
exports.handler = function(event, context) {
//console.log('Received event:', JSON.stringify(event, null, 2));  
var operation = event.operation;
delete event.operation;
switch (operation) {
case 'create':
var conn = mysql.createConnection({
host      :  'lamdatest.********.rds.amazonaws.com' ,  // RDS endpoint 
user      :  'user' ,  // MySQL username 
password  :  'password' ,  // MySQL password 
database  :  'rdslamda' 
});
conn.connect();
console.log("connecting...");
conn.query ( 'INSERT INTO login (name,password) VALUES("use6","password6")' ,     function(err, info){
        console.log("insert: "+info.msg+" /err: "+err);
    });
console.log("insert values in to database");
break;
case 'read':
dynamo.getItem(event, context.done());
break;

default:
context.fail(new Error('Unrecognized operation "' + operation + '"'));

}
context.succeed();
};  

When i checked out the mysqli-error.log file in the RDS it's shows an error given below.

2015-08-09 19:36:24 2630 [Warning] IP address '117.253.192.122' could not be resolved:  
Temporary failure in name resolution  

----------------------- END OF LOG ----------------------
7
  • what does the security group look like for this database? and to confirm, the quoted mysqli-error.log is from the Lambda service? Commented Aug 10, 2015 at 0:32
  • The security group is default. the quoted mysqli-error.log is from RDS instance console.it has created when i invoked the lambda function. Commented Aug 10, 2015 at 4:54
  • the description for the security group is:default VPC security group Commented Aug 10, 2015 at 5:04
  • What are the contents of the security group? Also, that IP does not belong to AWS; Lambda does not run on that IP. Commented Aug 10, 2015 at 5:07
  • Sorry the security group details are here. Type: MYSQL/Aurora, Protocol:TCP, PortRange:3306, Source: 0.0.0.0/0. Commented Aug 10, 2015 at 5:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.