MongoDB和Google Cloud Functions VPC是对等的吗? [英] MongoDB and Google Cloud Functions VPC Peering?

本文介绍了MongoDB和Google Cloud Functions VPC是对等的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从Google Cloud功能访问MongoDB Atlas时遇到问题.这给了我关于IP白名单的错误,但是我已经将(无服务器VPC访问)IP地址范围和VPC网络对等IP地址范围都添加到了MongoDB白名单中.

我还创建了与Google Cloud对等的MongoDB.

如果我允许(从任何地方访问),则mongodb可以正常工作,否则会出现有关IP白名单的错误.

我不确定已经添加了两个IP的情况下还应该添加到MongoDB白名单中的内容.

有人可以帮助我吗?一个简单的循序渐进指南将具有很大的意义.(如果可能,图片/视频可能会大有帮助)

** 编辑

我用(Atlas GCP项目ID和Atlas VPC名称)创建了(VPC网络对等).它们都是(活动且可用).

然后,我创建了(无服务器VPC访问权限).

并将其添加到我在(连接)中的函数中,该函数将连接到mongoDB以获取数据.如果将mongoDB设置为(允许从任何地方开始),但如果没有它,将无法正常工作.

然后,我在IP白名单中添加了所有3个IP/CIDR块.

  • MongoDB Atlas的CIDR块,如第一幅图像所示.
  • 并且CIDR阻止了无服务器VPC访问.
  • 还有来自VPC Network的CIDR Blcok和上面的所有内容.

但是我仍然感到困惑,当我运行此功能时,它仍然会给我关于IP白名单的错误,并且仅当我允许mongoDB中任何地方的流量时才起作用.

不知道我做对了什么,我做错了什么.由于互联网上没有任何视频可以实现这一目标.

我什至尝试了这篇文章,但仍然没有解决问题.

解决方案

如果您知道需要将特定IP列入白名单:

  • 将所有IP列入白名单.
  • 连接成功.
  • 下载服务器日志.
  • 找出连接来自哪个IP.
  • 将该IP列入白名单.

验证此IP在您的预期范围内,等等.

如果您知道不需要将特定IP列入白名单:

  • 这样说的Atlas参考文档,并解释了VPC对等应该如何工作(中级职位不能代替官方文档).

如果您不知道是否需要等待特定IP:

  • 按照第一个步骤,将您的IP列入白名单.
  • 然后查找官方文档,说明正确的用法.

I've having issues accessing MongoDB Atlas from Google Cloud functions. It is giving me error regarding IP Whitelisting but I've added both (Serverless VPC Access) IP address range and VPC Network Peering IP address range to MongoDB whitelist.

I've also created MongoDB peering with google cloud.

If I allow (access from anywhere) then my mongodb starts working fine, otherwise it gives error regarding IP whitelisting.

I'm not sure what else I should add to MongoDB whitelist when I've added both IP's already.

Can anyone help me regarding this? A simple step by step guide will mean a lot. (images/video can help big if possible)

**Edit

I took (Atlas GCP Project ID & Atlas VPC Name) to create (VPC Network Peering). And they both are (Active & Available).

And after that I created (Serverless VPC Access).

And added it to my function inside (connection), a function that will connect to mongoDB to get data. It works fine if I set mongoDB to (allow from everywhere) but do not work without it.

And after that I added all 3 IP's/CIDR blocks to the IP Whitelist.

  • The CIDR Block from MongoDB Atlas as in 1st image.
  • And CIDR Block from Serverless VPC Access.
  • And CIDR Blcok from VPC Network as well just like all above.

But I've still confused that when I run this function it still gives me error about IP Whitelist and only works if I allow traffic from everywhere in mongoDB.

Don't know what I'm doing right and what I'm doing wrong. As there aren't any videos available on internet to achieve this.

I even tried this article but still nothing works out.

https://medium.com/better-programming/connecting-google-cloud-functions-with-mongodb-atlas-499a0a82ccf3

This is the error I'm getting.

解决方案

If you know you need to whitelist specific IPs:

  • Whitelist all IPs.
  • Connect successfully.
  • Download server log.
  • Figure out which IP the connection came from.
  • Whitelist that IP.

Verify this IP is in your expected range, etc.

If you know you don't need to whitelist specific IPs:

  • Reference Atlas documentation that says so and explains how VPC peering is supposed to work (medium posts are not a substitute for official documentation).

If you don't know whether specific IPs need to be waitlisted:

  • Follow the first procedure and whitelist your IPs.
  • Then look for official documentation stating what the proper usage would be.

这篇关于MongoDB和Google Cloud Functions VPC是对等的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆