Build a simple automated deployment pipeline for Cloud Run (Step by step tutorial)


  • Container Registry -: It will store all Docker Images to be used in Cloud Run
  • Google Storage -: It will save our state of Terraform.
  • Cloud Run -: Serverless platform where our final app will be hosted
  • Terraform -: It will help us to spin up Cloud Run instance and to create multiple working environments like staging and production
  • Go -: It will help us to trigger Terraform command whenever we want to with Github Actions
  • Github Actions -: It will help us as an entry point to trigger those Go command and Go will trigger terraform

Why Cloud Run, Go, and Terraform?

Cloud Run




  1. You are familiar with how Go works
  2. You are familiar with how Cloud Run works i.e specifying container image. If not check this article
  3. You are familiar with how Terraform spins up a new server and how Terraform manages state
  4. You are familiar with Dockerizing the application.

Deployment tutorial steps

1. Dockerize application

2. Infrastructure setup with Terraform

terraform apply -var image_tag=docker_image_tag -var-file=dev.tfvars -auto-approve

3. Triggering Terraform with Go

cmd := exec.Command(“terraform”, “init”, “-backend-config”, “bucket=tf-test-app”)

4. Glue everything with Github Action and Bash file

Add More Environments

func getTfVarFileName(env string) string {if env == "dev" {return "dev.tfvars"}if env == "production" {return "prof.tfvars"}panic("Please select correct environment only dev & production available at the moment")}func getCredentialsFilePath(env string) string {if env == "dev" {return "credentials/dev-cred.json"}if env == "production" {return "credentials/prod-cred.json"}panic("error on loading credentials")}





Software Development Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

QA’s role in XP

GMAT, GRE Functions and Graphing Question

GMAT, GRE, QUANT, quantitative, math, test prep, functions

Flutter Basics-Material Component Widgets — Protorix India

Inline validation is problematic

AWS CodeCommit Repository Setup

AWS CodeCommit under Developer Tools

Is Platform Engineering the New DevOps or SRE?

HP MJF 3D Printing Pricing | DigiFabster Makes MJF Quoting Easy | DigiFabster

How to Create Faster Arrays in Python Using NumPy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ujwal dhakal

ujwal dhakal

Software Development Enthusiast

More from Medium

How Can I minimize my AWS Bills $$ based on…

Cloud Native File Integrity Monitoring

Infrastructure Diagram

Backup & Archive with AWS

GitHub Actions on Google Cloud Platform via