Code Snippets HCL

Short texts HCL 🧑‍💻 Code snippets HCL ✍️ Reading lists HCL 👀

network.tf

resource “google_compute_network” “gke_vpc” { name = local.vpc_name auto_create_subnetworks = false } resource “google_compute_subnetwork” “gke_subnet_germany” { name = “${local.vpc_name}-subnet-germany” ip_cidr_range = “10.10.0.0/20” network = google_compute_network.gke_vpc.self_link region = local.region_germany private_ip_google_access = true } resource “google_compute_subnetwork” “gke_subnet_finland” { name = “${local.vpc_name}-subnet-finland” ip_cidr_range = “10.20.0.0/20” network = google_compute_network.gke_vpc.self_link region = local.region_finland private_ip_google_access = true }

container_cluster.tf

resource “google_container_cluster” “gke_cluster” { name = var.cluster_name location = var.region // Making it regional initial_node_count = 1 network = var.network subnetwork = var.sub_network enable_legacy_abac = true node_config { tags = var.tags } }

named_port.tf

resource “google_compute_instance_group_named_port” “named_port_0” { group = google_container_cluster.gke_cluster.instance_group_urls[0] name = “http” port = 30000 }

two_clusters.tf

module “cluster_germany” { source = “./compute_module” region = local.region_germany cluster_name = “gke-cluster-germany” tags = [local.target_tag_germany] network = google_compute_network.gke_vpc.name sub_network = google_compute_subnetwork.gke_subnet_germany.name } module “cluster_finland” { source = “./compute_module” region = local.region_finland cluster_name = “gke-cluster-finland” tags = [local.target_tag_finland] network = google_compute_network.gke_vpc.name sub_network = google_compute_subnetwork.gke_subnet_finland.name }

kubernetes.tf

provider “kubernetes” { alias = “cluster-germany” version = “1.7.0” host = module.cluster_germany.endpoint token = data.google_client_config.current.access_token client_certificate = base64decode(module.cluster_germany.client_certificate) client_key = base64decode(module.cluster_germany.client_key) cluster_ca_certificate = base64decode(module.cluster_germany.cluster_ca_certificate) } provider “kubernetes” { alias = “cluster-finland” version = “1.7.0” host = module.cluster_finland.endpoint token = data.google_client_config.current.access_token client_certificate = base64decode(module.cluster_finland.client_certificate) client_key = base64decode(module.cluster_finland.client_key) cluster_ca_certificate = base64decode(module.cluster_finland.cluster_ca_certificate) }