Infrastructure
This provisions the cloud infrastructure Confident AI runs on: a GKE cluster, a Cloud SQL PostgreSQL database, GCS buckets, and the keyless identity wiring. When it finishes you will have a running cluster and a set of outputs to feed into the Helm chart on the next page.
Set your project and region once, and enable the APIs the module uses:
Create the network (optional)
Skip this if you already have a VPC network with a subnet that has two secondary ranges (pods and services) and Cloud NAT for its private nodes. Use your existing names in the next step.
GKE needs one subnet with two secondary ranges, one for pods and one for services, plus Cloud NAT so the private nodes can pull images. Run the blocks in order.
Create the VPC network in custom subnet mode so you define the subnet yourself:
Create the subnet with the two secondary ranges GKE needs:
ClickHouse runs cleanly on the IPv4-only GKE cluster this module builds: the chart pins the operator’s pods to listen on IPv4 (0.0.0.0), so there is no address-family error and no dual-stack setup is required. A dual-stack subnet alone would not change this, the nodes stay IPv4-only unless the cluster itself is created dual-stack.
Add a Cloud Router and NAT so the private nodes reach the internet for outbound pulls, with no inbound exposure:
Mirror the code sandbox image (required)
Code-based and transformer metrics run in a sandboxed Cloud Run service, which runs the confident-code-sandbox-gcp image. It must live in your own Artifact Registry before Terraform creates the service, so mirror the public image.
Create an Artifact Registry repository and let Docker authenticate to it:
Pull the public image and push it to your repository:
Write the Terraform config
Create a main.tf that references the published module, then fill in your project and the network names from the earlier steps. What each variable does:
- Project and network:
confident_gcp_project_id,confident_gcp_region, and the network names from the network step. - Naming:
confident_environmentandconfident_environment_codestamp theprodnaming convention onto every resource. - Access:
confident_public_gkeexposes the cluster API to your machine; set itfalsefor a private-only endpoint. - Database:
confident_psql_passwordsets your own PostgreSQL password; omit it to auto-generate one. - Managed services:
confident_create_secret_managerandconfident_managed_redis_enabledturn on the recommended secret store and Redis. - Code executor:
confident_ar_repository_nameis the Artifact Registry repo holding the image you just mirrored.
Prefer to work inside the repo? Clone terraform-google-confident-ai and put the same variables in a terraform.tfvars file instead of a module block.
Configure remote state (optional)
Skip this to use local state. For a team or a real environment, keep state in a GCS bucket.
Create a backend.tf:
Managed secrets and Redis (recommended)
The module block above provisions both. The Deploy page installs the External Secrets Operator and wires them into the chart:
- Secret Manager + External Secrets Operator (
confident_create_secret_manager = true): Terraform creates the secret and a Workload-Identity-bound service account for ESO. - Memorystore for Redis (
confident_managed_redis_enabled = true): managed Redis instead of the in-cluster one.terraform output -raw redis_urlgives the value forredis.externalUrl.
Prefer a simpler footprint? Set both to false to hold secrets in a Kubernetes Secret and run Redis in the cluster. See Simpler option on the Deploy page.
Inputs reference
The variables you are most likely to set. For the complete, always-current list, see the module inputs on the Terraform Registry.
Required
Commonly set (optional, with production defaults)