Accessing VM from Google Cloud Function

Solution 1:

I would suggest you go for Google's Cloud Run. Just like Cloud Functions, Cloud Run is serverless (you don't provision any servers and it scales to zero) but the distinction is that what is executed is a docker container.

Within that container, your "code" is executed in the container environment when called. Since it is running in a container, you can run bash script and providing any scripts or other environment needed to be able to run.