Warm tip: This article is reproduced from stackoverflow.com, please click
google-app-engine mongodb whitelist mongodb-atlas

Whitelisting IPs of a Node.js App (hosted on GAE) to access MongoDB Atlas (hosted on GCP)

发布于 2020-03-29 20:59:22

I want my backend server (Node.js, hosted on Google App Engine, flexible environment if that matters) to be able to grab and pass data from my database (MongoDB, through Atlas, also hosted on Google Cloud platform, in the same region as my backend server). Ideally, I'd like to keep a tight whitelist of IPs that can access my database, but I'm not sure how to identify them.

My understanding is that Google will use a range of IPs. I might be able to access these by querying Google from time to time (Google App Engine - list of IP addresses?).

I also found a nice tutorial from Google about how to connect App Engine to MongoDB Atlas, but they conveniently left out how to whitelist the correct IPs (https://cloud.google.com/community/tutorials/mongodb-atlas-appengineflex-nodejs-app).

I also found some notes from Atlas about using network peering within GCP (which I qualify for? see link: https://docs.atlas.mongodb.com/security-vpc-peering/) but there are significant restrictions, including that other IPs aren't allowed? I'm having a hard time understanding their documentation.

Key Question: Is there an easier way to do this than the first link above? Or am I stuck querying this frequently and changing it by hand?

Questioner
MattPM
Viewed
88
gso_gabriel 2020-01-31 18:14

It's not very easy or good to use IPs with App Engine. For cases like this, I would say that using VM on GCE - which you can configure external and internal static IP addresses - with the use of Proxy.

You can find more information on Reserving a static external IP address and Reserving a Static Internal IP Address , if you think this is a method that would help you.

There is a Feature Request open for static IP to be checked and possibly implemented by Google that you can access here:

Besides that, you can access the documentation Static IP Addresses and App Engine apps, to find out more information on options already available on App Engine.

Please, let me know if the information helped you.