Last reviewed: May 2026
Build the AWS services on the GAIL exam with plain Terraform — one block at a time, each tied back to an exam domain. The same code works on OpenTofu.
By the end of this lab you'll have provisioned, with plain Terraform, the smallest realistic Google GenAI substrate — Vertex AI and Discovery Engine APIs enabled, a Vertex AI Workbench instance for prototyping, a Discovery Engine data store that's the grounding-source primitive for RAG and Vertex AI Search, and a Cloud Monitoring alert on Vertex prediction error rate. Four blocks; the GAIL conceptual landscape mapped to actual provisioned infrastructure.
Drop the snippets into a single main.tf, run terraform init, then terraform apply step-by-step.
>= 1.5 or OpenTofu >= 1.6.your-project-id in the provider block.~$50/month if the Workbench is left running 24/7. Stop it after each lab session.
Enable Vertex AI, Discovery Engine (Vertex AI Search), Cloud Notebooks, and Cloud Monitoring APIs.
terraform {
required_version = ">= 1.5"
required_providers {
google = { source = "hashicorp/google", version = "~> 6.0" }
}
}
provider "google" {
project = "your-project-id" # REPLACE
region = "us-central1"
}
locals {
labels = {
project = "certlabpro-gail"
managed_by = "terraform"
}
}
resource "google_project_service" "aiplatform" {
service = "aiplatform.googleapis.com"
disable_on_destroy = false
}
resource "google_project_service" "notebooks" {
service = "notebooks.googleapis.com"
disable_on_destroy = false
}
resource "google_project_service" "discoveryengine" {
service = "discoveryengine.googleapis.com"
disable_on_destroy = false
}
resource "google_project_service" "monitoring" {
service = "monitoring.googleapis.com"
disable_on_destroy = false
}Vertex AI Workbench is the Jupyter-in-the-cloud surface every GenAI prototyping flow on GCP starts from — equivalent to Amazon SageMaker Studio / Azure ML Workbench. GAIL exam tests this as the go-to data-scientist seat primitive.
We provision a small e2-standard-2 Workbench instance pre-loaded with the GenAI Python libraries. The Workbench runs in a managed Compute Engine VM under the hood — you'll see it in the GCE console too. Stop the instance via the Vertex AI Workbench console when not actively using it to avoid ~$50/month while idle.
resource "google_workbench_instance" "main" {
name = "certlabpro-gail-workbench"
location = "us-central1-a"
gce_setup {
machine_type = "e2-standard-2"
boot_disk {
disk_size_gb = 100
disk_type = "PD_STANDARD"
}
}
labels = local.labels
depends_on = [google_project_service.notebooks]
}Discovery Engine (formerly Vertex AI Search) is the GAIL exam's flagship RAG primitive — point it at a corpus (GCS bucket, website crawl, BigQuery dataset, or structured JSON), it indexes the content, and downstream Gemini calls can ground their answers in that corpus.
We create a data store of type GENERIC — the conceptual container for indexed content. Production deployments populate the store with documents via the Discovery Engine API; for the lab, the empty store is the demonstration that the resource exists and bills accordingly.
The GAIL exam tests this data store → search app → grounded answers triangle as the standard enterprise-RAG-on-GCP shape.
resource "google_discovery_engine_data_store" "main" {
data_store_id = "certlabpro-gail-store"
display_name = "GAIL lab data store"
location = "global"
industry_vertical = "GENERIC"
content_config = "CONTENT_REQUIRED"
solution_types = ["SOLUTION_TYPE_SEARCH"]
depends_on = [google_project_service.discoveryengine]
}GenAI workloads have an operational dimension the GAIL exam keeps surfacing: prediction errors, latency, cost-per-token. We wire a Cloud Monitoring alert on Vertex AI's prediction error metric — fires when the error rate exceeds 5% over 5 minutes.
With four blocks in place (provider+APIs, Workbench for prototyping, Discovery Engine data store for grounding, and a Cloud Monitoring tripwire for operational health), the GAIL conceptual landscape is mapped to actual provisioned infrastructure. Real GenAI deployments layer model garden picks, custom training, prompt management, agent builder, and Model Armor / Responsible AI controls on this foundation — but the substrate above is the shape you'll see in GAIL exam scenarios.
resource "google_monitoring_alert_policy" "vertex_prediction_errors" {
display_name = "GAIL lab — Vertex AI prediction error rate"
combiner = "OR"
conditions {
display_name = "Prediction error rate > 5% over 5 minutes"
condition_threshold {
filter = "metric.type=\"aiplatform.googleapis.com/prediction/online/error_count\" AND resource.type=\"aiplatform.googleapis.com/Endpoint\""
duration = "300s"
comparison = "COMPARISON_GT"
threshold_value = 0.05
aggregations {
alignment_period = "60s"
per_series_aligner = "ALIGN_RATE"
}
}
}
# notification_channels = [] # add channels via console or separate TF resource
depends_on = [google_project_service.monitoring]
}terraform destroy tears down everything. The Workbench instance stops billing immediately on destroy (~$50/month saved). The Discovery Engine data store destroys cleanly (no per-resource minimum charge to worry about). The monitoring alert policy detaches.
GAIL covers many GenAI-on-GCP surfaces this lab can't fit — Gemini model picks (Gemini Pro / Gemini Flash / Gemini Nano), Vertex AI Model Garden (Anthropic Claude, Meta Llama, Mistral, etc.), Vertex AI Agent Builder (no-code agent provisioning), Vertex AI Pipelines (Kubeflow Pipelines + custom MLOps), Vertex AI Prompt Optimizer, Model Armor / Responsible AI tooling, Vertex AI Feature Store, AutoML, custom training jobs, the entire Generative AI Studio console, BigQuery ML's GenAI surface, Workspace GenAI features (Help me write / Help me organize), Gemini for Google Cloud (the IDE assistant), and Vertex AI Search & Conversation app provisioning (the next layer above data stores).
We stick to the Workbench + Data Store + Monitoring primitives because they're the smallest demonstrable shape. Workbench is where you prototype. Data Store is what RAG / Vertex AI Search reads. Monitoring is how you operate any of it. Master the substrate; the higher-level constructs (agents, pipelines, prompts) plug in via Vertex AI Studio.
For service-by-service conceptual coverage, see the Browse, Playbook, and Editorial sections of this cert page.