RDS mysql公共数据库无法从AWS Lambda连接

时间:2015-08-09 18:44:53

标签: mysql amazon-web-services lambda amazon-rds

我的RDS mysql公共数据库实例可以从mysql客户端连接。但是,当我在AWS Lambda中尝试相同时,它将无法正常工作。我的代码如下。

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();
};  

当我检查RDS中的mysqli-error.log文件时,它显示下面给出的错误。

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 ----------------------

0 个答案:

没有答案