我试图让我的 lambda 连接到 Postgres RDS。我的 lambda 和我的 postgres 实例位于同一个 VPC 和私有子网上。
在我的 lambda 上,我定义了一个安全组,如下所示:
Name: default-security-group
ingress: Allow all traffic from security group - default-security-group
egress: Allow all traffic on all ports out to all IPs 0.0.0.0/0
在我的 RDS 上,我定义了一个安全组,如下所示:
Name: rds-security-group
ingress: All traffic on port 5432 from security group - default-security-group
egress: Allow all traffic on all ports to all Ips 0.0.0.0/0
使用上述设置,我无法从 Lambda 连接到我的 RDS 实例。在玩了很多之后,只有当我更改我的 RDS 安全组以允许来自安全组 default-security-group 的所有端口时,它才起作用。
意思,
ingress: All traffic on port 5432 from security group - default-security-group
改为
ingress: All traffic on all ports from security group - default-security-group
我的问题是为什么我需要允许所有端口才能进行这项工作?