Assigning static IP to Node application in Google Cloud - node.js

I have delpoyed my Node.js application in Google Cloud and need to access our SQL database hosted in GCP. I am not able to configure static IP for the Node app to connect with DB.
Please suggest if configuring static IP in the Node app is the only way or any alternate way to permanently interact with the database hosted in the google cloud. Node app forms the backend of my android app.

Related

Can I only deploy the server side of my react native app to Heroku?

I have a react native app that I'm building using expo. For the backend, I am using node.js and Express.
My app hierarchy is such that I have a frontend folder and a backend (server) folder. For example,
Root
|
|Frontend
|Various screens & associated files
|Server
|Routes & other files
For my project, is it possible to just host the backend and not the rest of the app? Such that when I fetch data in the frontend using HTTP requests, instead of routing through localhost (http: //RandomIP:PORT/route) I would use the heroku address as the routing address. I would also host the SQL database along with it.
I tried to follow along with the Heroku documentation, but it seemed like that was for hosting the entirety of the app / web apps instead of mobile, and I ran into constant errors.
I would like to point out that, unlike web pages, mobile apps cannot be hosted on the server and fetched on-demand. In other words, do not try to upload your react-native code to Heroku instead just upload your backend only and then make HTTP requests through the URL provided by Heroku after you have deployed your code.
Therefore go into your backend codebase, initialize a git repository and just deploy that Heroku. Also, you will need to host your SQL database on another service such as Google's Cloud SQL or Amazons AWS Database Services.

HOW to deploy a MERN APP to production, without using firebase or heroku or aws

So people, I'm planning to build a website with MERN Stack and host it from my local machine. How to do that without using aws or fire base.
How to use my machine as Backend and database(express, node and mongodb hosted in local host) for the react frontend (hosted in www.someurl.com).
PS: I have already created a site using firebase and firestore as backend.
https://t-heros.web.app/
Thanks in advance.
One thing is you need to keep your local machine 24*7 for your app to work throughout the day. And for your answer you can expose your localhost to public domain by using static IP address and routing applicable from your router with appropriate firewall rules, all this also requires effort and maybe static IP address requires purchase. With both these together your React app can access the localhost on your machine for operations.

Connect to Compute Engine From App Engine or CLoud Run with firewall and IAP

I have an SFTP server running on Google's Compute Engine. The firewall is setup to allow traffic from the Identity aware proxy.
I can connect to the service using gcloud ssh locally but I can't connect from App engine or Cloud Run. The service accounts for Cloud Run and App engine already have IAP tunnel and Https permissions.
The backend is written in Node using ssh2-sftp-client.
How can I secure the Compute Engine and allow tcp traffic from Cloud Run and App Engine on port 22 to still go through?
Please look at the UPDATE below.
There are two possible workarounds:
If you use App Engine Standard you can try Serverless VPC Access:
Serverless VPC Access enables you to connect from your App Engine app
directly to Compute Engine VM instances, Memorystore instances, Cloud
SQL instances, and any other resources with an internal IP address.
Unfortunately, Serverless VPC Access isn't available for Cloud Run (more in documentation Services not yet supported) at the moment, but there's a Feature Request at the Google Public Issue Tracker you can join, comment and track progress. Also, such service isn't available for App Engine Flex as well.
If you use App Engine Flex or Cloud Run follow steps below:
reserve an external static IP
create f1-micro VM instance with reserved external IP address (this likely fits in the Compute Engine free tier)
create a firewall rule to allow connection to SFTP server from reserved external IP
create a SOCKS proxy by running a ssh client that routes the traffic through created VM like in this example
configure ssh2-sftp-client to use SOCKS Proxy
connect to SFTP
UPDATE:
No need to use any workarounds. Serverless VPC Access is now available for Cloud Run. Have a look at the documentation for more details.

Google Cloud App Connecting to Atlas MongoDB

I am a newbee to Google Cloud, however, I setup the project based on Standard App Engine based for my Node.JS application. I downloaded the code from GIT and able to deploy. In my code, it tries to make a Mongo connection to my Replication Server that is hosted at Atlas MongoDB (I guess it's on AWS EC2 instance). I have access control enabled so only server to server with known IPs can connect to my MongoDB.
Obviously I was expecting the connection from my freshly deployed app to fail. So to remediate I want to add the external IP of the instance from Google Cloud (whatever is the Public IP that is seen) to Mongo Network Access. I tried a few IP address I thought are the right ones but it's not working. I see the connection is trying to make to Atlas but it's failing because I am not sure what Public IP address is seen from AppEngine (Docker Instance?)where my app is running.
I tried 0.0.0.0/0 - open to all clients and my app works just fine, however I definitely don't want to open MongoDB access to entire world. If anybody knows more about Google Cloud please help.
Thanks in advance for replying if you have important info to share.
Google App Engine doesn't have an External/Static IP that you can refer. This can be achieved by using a VM on Google Compute Engine that has an External IP with proxy to your App Engine.
Besides that, there is a Feature Request open for this to be checked by Google that you can access here:
Provide static IP for outbound urlfetch requests
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.

Hosting azure app api on custom server

I am working on xamarin android. I want to connect my local DB to my mobile app. For this i have created a azure app api with swagger. Now i want it to use it locally i.e. i don't want it to host on azure portal all i want is to host it on my static IP on which I have bought. I have searched for this question but can't find any thing related to it. Is there a way to host my azure app api on custom server?
Any help would be highly appreciated

Resources