Note
- This is an experimental project. Tracing works, but not all of Langfuse's features have been verified to work.
Terraform configuration for self-hosting Langfuse on Google Cloud.
Our main branch will continuously support Langfuse v3. Langfuse v3 gained a solid and scalable architecture with the latest major update. You can also access v2 at v0.0.1 tag.
- Sreverless hosting on Cloud Run
- Secure data persistance with
- Cloud SQL
- Memorystore for Redis
- Cloud Storage
- Cloud Filestore (Mounted by Clickhouse on Cloud Run)
- Secure network with VPC
- Google Cloud account
- gcloud CLI installed
- Terraform installed
-
Clone the repository and move directories
git clone https://github.com/sotazum/langfuse-google-cloud-terraform.git cd terraform/google/environments/dev -
Set your own variables on
terraform.tfvars- Replace the value surrounded by
< >
- Replace the value surrounded by
-
Comment out
webmodule# # At initial terraform apply, the following resource "web" should be commented out to avoid an error. After pushing the image to the artifact registry, uncomment the resource "web" and apply the terraform configuration again. # module "web" { # source = "../../modules/web" # project_id = var.project_id # region = var.region # web_repository_id = var.web_repository_id # langfuse_version = var.langfuse_version # network_name = module.vpc.network_name # subnet_name = module.vpc.subnet_name # env_web = local.env_web # depends_on = [ module.worker ] # }
-
Google auth
gcloud auth login --update-adc -
1st Terraform init and apply
terraform init terraform apply -
Push custom web image
cd ../../../../ bash ./docker/cloudbuild.sh <your-project-id> <your-region> langfuse-web-repo 3 -
Migrate Terraform state to GCS
terraform init -migrate-state- Then generate
backend.tfand have Terraform state managed by a GCS bucket
- Then generate
-
Undo Comment out and 2nd Terraform apply
# At initial terraform apply, the following resource "web" should be commented out to avoid an error. After pushing the image to the artifact registry, uncomment the resource "web" and apply the terraform configuration again. module "web" { source = "../../modules/web" project_id = var.project_id region = var.region web_repository_id = var.web_repository_id langfuse_version = var.langfuse_version network_name = module.vpc.network_name subnet_name = module.vpc.subnet_name env_web = local.env_web depends_on = [ module.worker ] }
terraform apply -
Access to Langfuse
- Check your Cloud Run URL on Google Cloud Console (default:
https://langfuse-web-<your-project-number>.<your-region>.run.app)
- Check your Cloud Run URL on Google Cloud Console (default:
