Connect to a AWS RDS Proxy in Laravel

1.1k views Asked by At

I have a Laravel application deployed to AWS Lambda using Laravel Vapor. I want to use RDS Proxy instead of directly connecting to the RDS instance.

Laravel Vapor lets you manage a database and proxy from the dashboard and CLI. But, I am not using Vapor to manage my database. I am managing them through a cloud formation template.

I found no documentation to integrate a non-managed RDS Proxy with Laravel Vapor or Laravel in general.

I have tried few things but I am always getting the below error:

Illuminate\Database\QueryException SQLSTATE[HY000] [1045] Access denied for user 'gxadmin'@'%' (using password: NO)

Following are the things which I have tried.

  1. I have replaced the direct RDS endpoint with the Proxy endpoint in the environment.
  2. I have given necessary permission to the Lambda Role. Following is the policy:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "cloudwatch:GetMetricStatistics",
                "ec2:CreateNetworkInterface",
                "ec2:DeleteNetworkInterface",
                "ec2:DescribeNetworkInterfaces",
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:FilterLogEvents",
                "logs:PutLogEvents",
                "kms:Decrypt",
                "secretsmanager:GetResourcePolicy",
                "secretsmanager:GetSecretValue",
                "secretsmanager:DescribeSecret",
                "secretsmanager:ListSecretVersionIds",
                "secretsmanager:GetRandomPassword",
                "secretsmanager:ListSecrets",
                "ssm:GetParameters",
                "ssm:GetParameter",
                "lambda:invokeFunction",
                "s3:*",
                "ses:*",
                "sqs:*",
                "dynamodb:*",
                "route53domains:*",
                "es:*",
                "rds-db:connect"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}
  1. I have tried adding or removing "database-proxy: true" from the Vapor YAML file but the error is still the same.

I have found a PHP example here to connect to an RDS Proxy.

Does Laravel Vapor or Laravel in general support RDS Proxy? Or will I have to override the DB connection logic using the service container?

Please guide.

0

There are 0 answers