Issue trying to access mysql through VPC in AWS-RDS through lambda

ammusk354

Earning My Ears
Joined
Feb 17, 2023
Messages
2
I have setup a VPC and an RDS database using mysql through a nodejs lambda using serverless.

The issue I am having is that I get a server internal error when testing the lambda. The lambda is using the same VPC as the RDS.

Could this be a permission issue where the lambda needs direct permission to the db instance. If so does anyone have any suggestions on what permissions would be required.

Thankyou

Here is part of the code I am using, this is to test a query and log the result to cloudwatch. It does not show up and only shows timed out.

it seems to work locally using serverless. This is just for educational purposes.
Code:
 let pool  = mysql.createPool({
        host: host.length > 0 ? host : body.host,
        port: port.length > 0 ? port : body.port,
        user: body.username,
        password: body.password,
        database: body.dbname
    });

    pool.getConnection(function(err, connection) {
        connection.query('SELECT 1 + 1 AS result', function (error, results, fields) {
            // And done with the connection.
            //connection.release();
            // Handle error after the release.
            if (error) throw error;
            else Logger.info(JSON.stringify(results));
        });
    });
      return {statusCode:200, body: JSON.stringify({})};
}
 
Last edited:


Disney Vacation Planning. Free. Done for You.
Our Authorized Disney Vacation Planners are here to provide personalized, expert advice, answer every question, and uncover the best discounts. Let Dreams Unlimited Travel take care of all the details, so you can sit back, relax, and enjoy a stress-free vacation.
Start Your Disney Vacation
Disney EarMarked Producer






DIS Facebook DIS youtube DIS Instagram DIS Pinterest DIS Tiktok DIS Twitter

Add as a preferred source on Google

Back
Top Bottom