Reputation: 6769
I would like to call a function on compute engine from cloud function. I have a cloud function that gets triggered when a new file is dropped in cloud storage. I have a python function on compute engine that would process that file. How can I connect to compute engine from cloud function using python. Doesnt have to be using internal IP.
Upvotes: 1
Views: 1029
Reputation: 75715
The most recommended and secure way is to use the private IP to reach your compute engine. For this, you can use a serverless VPC connector in your Cloud Function.
Now, to allow your function to call your Compute Engine and to launch a process on it, your have (I think) 2 solutions.
The most recommended is to expose a simple flask server on your Compute Engine, and thus a simple HTTP service. This service triggers your Python code on the Compute Engine.
I think that you can find a Python lib to load in your Cloud Functions and to connect into your Compute Engine with SSH. Not sure, and it's not a good solution/pattern. I recommend you to not loose time on this.
Upvotes: 1