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

ammusk354

Earning My Ears
Joined
Feb 17, 2023
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:

GET A DISNEY VACATION QUOTE

Dreams Unlimited Travel is committed to providing you with the very best vacation planning experience possible. Our Vacation Planners are experts and will share their honest advice to help you have a magical vacation.

Let us help you with your next Disney Vacation!











facebook twitter
Top