我有一个 Lambda 函数,可以从 API 网关或 ALB 请求触发。我还有一个 RDS Aurora PostgreSQL 实例,它们都在 VPC 中运行。
我可以从 Lambda 很好地连接到 RDS 实例,但是我无法访问互联网,例如试图发出请求https://jsonplaceholder.typicode.com/todos/1会导致超时。
我也无法使用 DBeaver 等 SQL 客户端连接到远程数据库。
下面是一些详细信息,但如果您需要其他任何信息,请告诉我。我很困惑。
Lambda 入站规则
Security group ID Ports Source
sg-0f2c4426c8fc85235 80 0.0.0.0/0
sg-0f2c4426c8fc85235 5432 0.0.0.0/0
sg-0f2c4426c8fc85235 All sg-0f2c4426c8fc85235
sg-0f2c4426c8fc85235 22 0.0.0.0/0
sg-0f2c4426c8fc85235 443 0.0.0.0/0
Lambda 出站规则
Security group ID Ports Destination
sg-0f2c4426c8fc85235 All 0.0.0.0/0
RDS 连接
![rds](https://i.stack.imgur.com/2pxQD.png)
VPC
![vpc](https://i.stack.imgur.com/qqhhn.png)
Public Subnet
![pubsub](https://i.stack.imgur.com/s0jLs.png)
Private Subnet
![prisub](https://i.stack.imgur.com/7yJBx.png)
EDITS
Nat Gateway (associated with public subnet)
![nat](https://i.stack.imgur.com/WV6uI.png)
Route Tables
![rtables](https://i.stack.imgur.com/kLhIt.png)
Route Table Routes
![rtablerouteA](https://i.stack.imgur.com/UVPnI.png)
![rtablerouteB](https://i.stack.imgur.com/dLb6W.png)
![rtablerouteC](https://i.stack.imgur.com/AxpE7.png)
EDIT 2
Lambda 子网
![lamsub](https://i.stack.imgur.com/7dzRE.png)
Lambda 函数应该only连接到私有子网。
这使得 Internet 绑定的流量能够路由到公共子网中的 NAT 网关。
如果 Lambda 函数连接到公有子网,它将无法访问 Internet。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)