I am trying to connect to my SQL Server RDS instance from AWS Lambda in my VPC (using .net core).
When I attempt to run the Lambda function, it returns:
"errorType": "SqlException", "errorMessage": "Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=781; handshake=1957; [Login] initialization=40; authentication=122; [Post-Login] complete=12219;",
I have configured the following:
- Both the RDS instance and Lambda are in the same VPC
- Both the RDS instance and Lambda are in the same AZ and subnet
- The Lambda is in its own Security Group
- The RDS instance Security Group has given permission for port 1433 for the Lambda SG
- The Lambda IAM role has permission for AWSLambdaFullAccess, and AWSLambdaVPCAccessExecutionRole
- The MSSQL connection string (endpoint, user id, pwd, etc.) works from an EC2 instance in the same VPC/AZ/subnet.
The connection string looks like this (using Dapper as my ORM)
string dbconnstr = @"server=vpc100-db.xyz.us-west-1.rds.amazonaws.com;database=dbMyDb;user id=sa;password=mypwd;";
Any idea what I'm missing?