Cloud Run - Serverless runtime for containerized applications
Mongo Atlas - Fully managed MongoDB
Mongo Atlas requires IP address whitelisting, meaning that if the request isn’t coming from a whitelisted IP, it is blocked by the firewall.
Issue:
- Cloud Run’s external IP is ephemeral, meaning it can change at any time.
2.Solution:* Establish a peer connection/VPC connection between Mongo Atlas and a GCP VPC, and whitelist the VPC’s IP address ranges.Fix: VPC peering has been done. A VM was created to test the VPC connection to Mongo Atlas. Without any additional IP whitelisting, the connection to Mongo Atlas is successful. - However, serverless instances cannot access this VPC.
4.Fix:* A serverless connector to the VPC has been set up, and Cloud Run is configured to use this connector for all its communications (ideally, only MongoDB connections should go through this). - Despite these steps, Cloud Run is still unable to communicate with Mongo Atlas.
Questions:
- Do we need to set up a static IP address via NAT?
- Is there a simpler path to achieve a connection between Mongo Atlas and Cloud Run?