Reputation: 801
I have RDS MySQL database created under one AWS account. This DB is opened, i can connect by Workbench or by any other desktop app.
Also i have other AWS account where i'm trying to create Lambda function for to connect to RDS DB from my first account.
And looks like it's impossible because i'm every time getting timeout.
Here is my Lambda Java code:
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import java.sql.DriverManager;
public class DBTest implements RequestHandler<String, String> {
@Override
public String handleRequest(String input, Context context) {
context.getLogger().log("Input: " + input+"\n");
try {
StringBuilder url = new StringBuilder();
url.append("jdbc:mysql://").
append("jackdbinstance.********.eu-west-1.rds.amazonaws.com:3306/").
append("TestLambdaDB"+"?").
append("user=******&").
append("password=*******");
DriverManager.getConnection(url.toString());
return "DB connected";
} catch (Exception e) {
return e.toString();
}
}
}
Using same code i can connect from my desktop java app without any problems.
I'm not using VPC, i have allocated 512Mb memory for Lambda, timeout set to 30sec(from my view it's enough)
Can somebody help please?
Upvotes: 0
Views: 1167
Reputation: 801
Problem was connected with security group config for RDS instance, there was only one IP applied for to connect, somehow this rule was set automatically when i create RDS instance.
Upvotes: 4