Creating a Google Function with Gitlab integration in 10 minutes!

Massato Takaki
2 min readMay 11, 2020


Hello everyone!

I’m working in a side project and I needed to create a Google Functions for my back-end, using NodeJS, Google Cloud SQL with MySQL.

I will show you the easier way to create an integration between your Gitlab and Google Cloud Platform.

You can see my NodeJS Project example in my Github

  1. Let’s start creating an initial NodeJS project based on GoogleCloud Docs instructions.
    or clone my Github example project
  2. Let’s create a new project on Google Cloud Platform.
new project screen

Create a Service Account


Write your service account name

Grant the Roles:
-Cloud Functions Admin
-Service Account User


Create a JSON file, download and save to the project root

After creation you can see your Keys.

Now your project looks like this

3. Let’s create a integration

At the root of the project, create a file named: .gitlab-ci.yml

deploy to gcloud:image: google/cloud-sdk:latestscript:- gcloud auth activate-service-account — key-file=./gcloud-service-key.json- gcloud config set project PROJECT-GCP-NAME- gcloud functions deploy FUNCTION-NAME — runtime nodejs8 — trigger-http — allow-unauthenticated