Skip to content

Google Cloud Run Module for Terraform (Include with EGLB)

Notifications You must be signed in to change notification settings

chiqors/cloud_run_tfmodule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloud Run Terraform Module

This configuration deploys a Google Cloud Run (v2) service with optional global HTTP(S) load balancing. It supports environment variables, secret references, volumes (Cloud SQL, GCS, Secret), VPC access, and container startup probes.

Prerequisites

  • Terraform >= 1.4
  • Google provider hashicorp/google >= 5.0
  • A container image available in Artifact Registry (image_url)
  • Optional for load balancer: a reserved global static IP and, for HTTPS, a DNS-managed domain

Quick Start

  • Copy terraform.tfvars.example to terraform.tfvars and adjust values
  • Initialize: terraform init
  • Plan: terraform plan
  • Apply: terraform apply

Minimal Inputs

  • project_id (variables.tf:1)
  • region (variables.tf:6)
  • service_name (variables.tf:11)
  • image_url (variables.tf:16)
  • container_port (variables.tf:22)
  • artifact_registry_repo_url (variables.tf:116)

Common Options

  • environment_variables map for plain env vars (variables.tf:80)
  • secret_environment_variables map for secret-backed env vars (variables.tf:86)
  • min_instance_count / max_instance_count for scaling (variables.tf:50,56)
  • cpu_limit and memory_limit for container resources (variables.tf:62,68)
  • vpc_connector to enable Serverless VPC Access (variables.tf:110)
  • enable_startup_probe and related probe settings (variables.tf:242–276)

Load Balancer

  • Toggle with enable_load_balancer (variables.tf:162)
  • When enabled, provide resource names: serverless_neg_name, backend_service_name, url_map_name, http_proxy_name, forwarding_rule_name (variables.tf:168–196)
  • HTTPS support requires: enable_https, domain_name, ssl_certificate_name, target_https_proxy_name, https_forwarding_rule_name, redirect_url_map_name (variables.tf:205–239)

Outputs

  • service_id (outputs.tf:1)
  • service_name (outputs.tf:6)
  • service_url (outputs.tf:11)

Notes

  • The Cloud Run service resource is defined in main.tf (main.tf:1)
  • Global load balancing resources are defined in load_balancer.tf (load_balancer.tf:3)

About

Google Cloud Run Module for Terraform (Include with EGLB)

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages