可以使用 SQS 的 VPC 端点关闭私有子网中 Lambda 的开放入口吗?

Possible to close open ingress for a Lambda in private subnet with VPC Endpoint for SQS?

这与 本质上是同一个问题。但是,使用 VPC 端点的解决方案 使用 NAT 网关的解决方案对我不起作用,如下所述。

我的设置:

我的 Lambas 尝试发送到 SQS 时出现超时错误。但是,当我修改安全组以允许 open ingress 时,它起作用了!

问题:

  1. 如何为 VPC 中私有子网中的 lambda 发送到 SQS 的 SQS VPC 端点/NAT 网关解决方案设置安全组?
  2. 使用 VPC 端点是否需要打开入口?
  3. 如果是这样,为什么需要它?为了解决这个问题,我们尝试从 AWS 中提取 ip 范围 (here),但没有特定于 SQS 的 IP,因此我们被迫将所有这些都放在该区域并添加到一个安全组(或多个,因为有很多)。
  1. How are security groups meant to be setup for the SQS VPC Endpoint / NAT Gateway solutions for a lambda in a private subnet in a VPC to send to SQS?

VPC 端点应该有一个安全组,允许从分配给 Lambda 函数的安全组进入。

  1. Is open ingress a requirement to use VPC Endpoint?

VPC 端点的全部意义在于允许将连接发送到端点,然后将连接转发到 VPC 外部存在的服务。如果您不允许与 VPC 端点的任何入口连接,则该端点将无法工作。

  1. If so, why is it required? To combat this, we tried pulling the ip-ranges (here) from AWS but there are no SQS-specific IPs so we are forced to get all of them in the region and add to a security group (or multiple, since there are a significant number of them).

为什么要将 SQS IP 添加为 SQS VPC 端点的入口?我开始怀疑你是否混合了入口和出口。您说您的 Lambda 函数正在尝试发送到 SQS。发送是出口。 Lambda 函数需要一个允许出口到 SQS 的安全组。

VPC 端点需要接受来自 Lambda 函数的流量。来自 Lambda 函数的流量被视为 VPC 端点的入口流量。

对于通过 VPC 端点发送 SQS 消息的 Lambda 函数,您需要以下安全组:

Lambda 函数安全组:

入口:none

出口:端口 443 到 VPC 端点的安全组,或仅(全部)

VPC 端点的安全组:

入口:来自 Lambda 函数安全组的端口 443

出口:(全部)