Google 使用 http 调用云函数 POST - 仅限内部流量

Google Cloud function invoke with http POST - Internal traffic only

我有一个云函数 (fce_a),我需要从同一个 GCP 项目和区域中的不同云函数 (fce_b) 调用它。当我将 fce_a 设置为 Allow all traffic(在 Ingress settings 中)时,它工作得很好(使用 this method). However, when I set the fce_a to Allow internal traffic only (in Ingress settings) I am getting Error 403 (Forbidden) 403. That's an error. Access is forbidden. That's all we know. (mentioned here)。

我试过使用 this method,但它仅用于测试目的,而且限制对我的用例来说过于严格。

如果目标函数将 Ingress settings 设置为 Allow internal traffic only,是否知道如何从不同的云函数调用云函数?

Allow internal traffic only 仅允许来自同一项目或 VPC Service Controls 边界中的 VPC 网络的请求。由于云函数实际上 运行 在您的项目之外,因此您的函数 fce_b 无法按原样到达 fce_a

要允许此用例,您需要使用 VPC Connector to connect them to one of your VPC network in your project (you can use the same VPC conector for both functions since they're in the same region). Your fce_a, set with Allow internal traffic only, will accept traffic coming from that VPC connector. Note that, on your fce_b, you'll need to set Egress settings 来匹配您的用例。