繁体   English   中英

如何使用内部IP从Google Cloud Functions连接到我的Compute Engine MongoDB实例?

[英]How to connect to my Compute Engine MongoDB instance from Google Cloud Functions using the internal IP?

我的Google Cloud Functions与在Compute Engine VM Instance上运行的MongoDB数据库完美配合,但前提是我在Function的MongoClient连接字符串中使用实例的外部IP地址。

如果我使用内部IP,我理想情况下更喜欢使用延迟和安全性,它会在30秒后超时并显示:

document-create 4990695959542 DocumentCreate error: failed to connect to server [10.*.*.*:27017] on first connect [MongoError: connection 1 to 10.*.*.*:27017 timed out] document-create 4990695959542 
document-create 4990695959542 Function execution took 30025 ms, finished with status: 'timeout' document-create 4990695959542 
document-create 4990695959542 Function execution started document-create 4990695959542

我的mongodb.conf如下:

# network interfaces
net:
    port: 27017
    bindIp: 127.0.0.1,10.*.*.*

显然, 10.*.*.*是我的内部计算引擎实例。 我在Google云端功能中的MongoClient连接字符串中使用的IP相同。

如果我使用我的外部IP并在mongodb.conf中我放了0.0.0.0,它可以工作。 我希望云功能使用VM的内部IP连接到我的MongoDB计算引擎实例。

有帮助吗?

目前这是不可能的。 云功能存在于与项目的专用VPC不同的网络上,因此只有公共IP访问可用。

创建一个问题来请求此功能,您可以在其上添加您的请求并订阅更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM