2

I am trying to hook up AWS RDS Aurora database with AWS Lambda Java function. For this, I am yet to see any concrete examples. I have seen some examples but they are non java.

I would also like to configure a mySQL DBMS tool with Aurora which I am not able to do :( Can someone help me with that as well. I have got the connection strings from https://console.aws.amazon.com/rds/home?region=us-east-1#dbinstances.

Also, the code I am trying to connect to DB via Lambda Java is:

private Statement createConnection(Context context) {
    logger = context.getLogger();
    try {
        String url = "jdbc:mysql://HOSTNAME:3306";
        String username = "USERNAME";
        String password = "PASSWORD";

        Connection conn = DriverManager.getConnection(url, username, password);
        return conn.createStatement();
    } catch (Exception e) {
        e.printStackTrace();
        logger.log("Caught exception: " + e.getMessage());
    }
    return null;
}

And yes, this doesn't help as I always get null using the db instance config.

Security groups added to db isntance

5
  • 1
    Is your RDS inside a VPC? And is your Lambda function inside that VPC? Commented Sep 19, 2017 at 1:42
  • Adding to what dasmug asked as well, what is the security groups for both the RDS db and the Lambda function. Commented Sep 20, 2017 at 13:22
  • @strongjz RDS has all security groups added. There were 4. I also tried hooking it to SequelPro which fails as well Commented Sep 20, 2017 at 20:15
  • Added where? I meant in the question, what the vpc questions? Commented Sep 20, 2017 at 20:17
  • Updated in the original question with a screenshot. @strongjz Commented Sep 20, 2017 at 21:12

1 Answer 1

1

RDS needs be in a security group that opens the DB port to the Security Group attached to the ENI of the lambda.

To enable your Lambda function to access resources inside your private VPC, you must provide additional VPC-specific configuration information that includes VPC subnet IDs and security group IDs. AWS Lambda uses this information to set up elastic network interfaces (ENIs) that enable your function to connect securely to other resources within your private VPC.

http://docs.aws.amazon.com/lambda/latest/dg/vpc.html

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html

Sign up to request clarification or add additional context in comments.

Comments

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.