AWS Lambda - 无法连接到 VPC 中的 SQL 服务器 RDS

AWS Lambda - Unable to connect to SQL Server RDS in VPC

我正在尝试从我的 VPC 中的 AWS Lambda 连接到我的 SQL 服务器 RDS 实例(使用 .net 核心)。

当我尝试 运行 Lambda 函数时,它 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;",

我配置了以下内容:

连接字符串如下所示(使用 Dapper 作为我的 ORM)

string dbconnstr = @"server=vpc100-db.xyz.us-west-1.rds.amazonaws.com;database=dbMyDb;user id=sa;password=mypwd;";

知道我错过了什么吗?

已解决。数据库引擎版本是问题。

事实证明,这不是 Lambda 或 VPC 和 RDS 的权限问题。无法从 Lambda(通过 c#.net 核心)连接到 RDS 是数据库版本!我正在连接到 RDS MS SQL 2008 R2,它使用本地代码而不是 Lambda。当我将 RDS 目标数据库更改为 MS SQL 2016 时,它起作用了!