Deploying FastAPI with Terraform and Cloud Run

github repo

Hardcoded for project intentos-dev and region us-central1.

Contents

  • FastAPI app with /healthz
  • Terraform for enabling APIs, VPC + Serverless VPC Connector, Artifact Registry
  • Makefile helpers for build/deploy

Prereqs

  • gcloud CLI authenticated to intentos-dev
  • terraform >= 1.7
  • Docker

Quick Start

# 1) Infra
cd infra/envs/dev
terraform init
terraform apply -auto-approve

# 2) App (local run)
cd ../../..
python -m venv .venv && source .venv/bin/activate
pip install -r app/requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8080

# 3) Build & Deploy to Cloud Run (optional)
make build
make push
make deploy

Note: Creating a brand-new GCP project via Terraform requires org_id and billing_account which are not included here. This scaffold assumes intentos-dev already exists. The enable_apis module activates required services in that project.

hjkl / arrows · / search · :family · :tag · :datefrom · :dateto · ~/entries/slug · Ctrl+N/Ctrl+P for suggestions · Ctrl+C/Ctrl+G to cancel
entries 201/201 · entry -/-
:readyentries 201/201 · entry -/-