Terraform-GCP: Serverless Data Process plus Compute Engine for Web App

Saverio Mazza
2 min readJan 18, 2024

--

The project focuses on setting up a comprehensive infrastructure using Google Cloud Platform (GCP) services for serverless applications and web deployment. It leverages Terraform for infrastructure as code (IaC) to create a robust, scalable environment for handling event-driven processes and web app deployment. The key components include Cloud Run, Compute Engine, Cloud SQL, and a Virtual Private Cloud (VPC).

https://github.com/mazzasaverio/terraform-gcp

The primary aim is to automate the processing of unstructured data (PDFs), using Cloud Build for continuous integration and Cloud Run for serverless execution. A Compute Engine instance is utilized for deploying a web application where data analyses are displayed.

Core Components

  1. VPC Configuration: Establishes a dedicated network for all services, enhancing security and connectivity.
  2. Compute Engine Setup: A virtual machine for web app deployment, reading from Cloud SQL via private IP.
  3. Cloud Run Creation: Serverless execution of applications, directly connected to Cloud SQL, triggered by storage uploads.
  4. Automated Cloud Build: Continuous integration setup that triggers builds and updates Cloud Run with new Docker images.

Prerequisites

  • Active Google Cloud Platform account.
  • Setup of a new GCP project with billing enabled.
  • Creation of a service account with ‘Owner’ permissions and a JSON key file.
  • Configuration of Cloud Build and GitHub integration for CI/CD.
Terraform-GCP

Cloud SQL Connection via Cloud SQL Proxy

Instructions for setting up a secure connection to Cloud SQL using the Cloud SQL Proxy, beneficial for local development and database management tools like DBeaver.

This repository serves as a comprehensive guide for setting up a GCP-based infrastructure using Terraform, addressing various needs from serverless processing to web app deployment. It’s a valuable resource for anyone looking to implement a similar setup and invites community contributions and suggestions for improvements.

--

--