Unable to connect to any of the specific MySQL hosts with AWS Lambda to RDS MySQL

1

I have an AWS Lambda function for an API. I have a test function inside of the API that returns a "Success" string so I know that I can hit the API from my machine (Postman).

The Lambda API is inside of my VPC. I have public and private subnets. The API is living in the public subnets. I also have a RDS database that's living in the private subnets. I can connect to the database through a Bastion host so I know the database is connected and working.

When I try an API call that connects to the database, I can see an error in CloudWatch that says:

[Error] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: Unknown error responding to request: MySqlException: MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.InvalidOperationException: Sequence contains more than one matching element

There's a lot of references to that error message that talks about the Linq SingleOrDefault() method, but I don't have any references to that method.

I think that error has something to do with the security groups. I have an RDS security group that has an inbound rule on port 3306 from my internal VPC ip addresses.

The security group for my Lambda function should be ok since I can successfully hit the test route.

Finally, I tried connecting to the database through the API in debug on my machine and I get an error "The requested name is valid, but no data of the requested type was found"

Does anyone have any other ideas or places to look?

amazon-web-services
aws-lambda
amazon-rds
amazon-vpc
aws-security-group
asked on Stack Overflow Dec 18, 2019 by John Rousseau • edited Dec 18, 2019 by John Rousseau

1 Answer

0

Can you check your this setting is enable or not for RDS Security group ?

Inbound RDS Security Group

Outbound RDS Security Group

Disclaimer : Allowing inbound traffic on DB from internet is not recommended and should always be avoided

answered on Stack Overflow Dec 18, 2019 by aviboy2006 • edited Dec 18, 2019 by aviboy2006

User contributions licensed under CC BY-SA 3.0