Configuration Files
Production-ready configuration files with detailed comments and best practices. Each file works together as a complete deployment solution.
# main.tf - GKE Cluster with Terraform
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.0"
}
}
}
provider "google" {
project = var.project_id
region = var.region
}
resource "google_container_cluster" "primary" {
name = var.cluster_name
location = var.region
# We can't create a cluster with no node pool
remove_default_node_pool = true
initial_node_count = 1
network = "default"
subnetwork = "default"
# Enable Autopilot for managed Kubernetes
enable_autopilot = true
# Workload Identity for secure pod authentication
workload_identity_config {
workload_pool = "${var.project_id}.svc.id.goog"
}
}
# variables.tf
variable "project_id" {
description = "GCP Project ID"
type = string
}
variable "region" {
description = "GCP region"
type = string
default = "us-central1"
}
variable "cluster_name" {
description = "GKE cluster name"
type = string
default = "my-gke-cluster"
}