1
votes

I have a google cloud function which needs to access the MongoDB hosted on Atlas (GCP). This cloud function needs to access a specific API hosted outside GCP. For security reasons they need to allow the cloud functions IP address on their firewall rules.

To enable the static IP address request, I created a serverless VPC connector and configured all the egress traffic for my cloud function.

Once I configured, the connection for mongoDB from my cloud function is failing even if I allow all incoming traffic (just for testing).

I was thinking of VPC peering to allow cloud functions to access mongoDB, but I have not been able to configure it yet. The VPC pairing shows as "PENDING" state.

  1. Does Serverless VPC guarantee static IP address?

  2. Why am I not able to connect to mongoDB via serverless VPC connector even though all incoming traffic is allowed?

  3. Can we configure VPC peering between serverless VPC and mongodb atlas?

1

1 Answers

2
votes
  1. Yes, Serverless VPC access guaranty a static IP address is you perform the correct set up (use a Cloud Nat and a router for routing the Serverless VPC Access IP-Range through Cloud Nat and use a static IP in Cloud Nat)

  2. You aren't able to reach MongoDB via serverless VPC connector because your routes aren't well defined, and because of the point 3

  3. You can perform a peering between MongoDB Atlas and your VPC. For this, follow this page. If you peering is in pending state, I think that is because the GCP part has not been performed. Then define correctly your route and be sure that your firewall allow communication, and that should work!