Skip to content

Commit

Permalink
feat: add dependencies for storage buckets and remove unused GKE clus…
Browse files Browse the repository at this point in the history
…ter resources
  • Loading branch information
Gezi-lzq committed Nov 14, 2024
1 parent abfe6c8 commit 21ec6b6
Showing 1 changed file with 2 additions and 112 deletions.
114 changes: 2 additions & 112 deletions google.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ resource "google_storage_bucket" "automq_byoc_ops_bucket" {
}

data "google_storage_bucket" "ops_bucket" {
depends_on = [ google_storage_bucket.automq_byoc_ops_bucket ]
name = local.automq_ops_bucket
}
data "google_storage_bucket" "data_bucket" {
depends_on = [ google_storage_bucket.automq_byoc_data_bucket ]
name = local.automq_data_bucket
}

Expand Down Expand Up @@ -500,115 +502,3 @@ resource "google_compute_firewall" "allow_googleapis_ipv4" {
direction = "EGRESS"
}



# Create GKE cluster and node pool
resource "google_container_cluster" "automq_gke_cluster" {
name = "gke-cluster-${var.automq_byoc_env_id}"

location = var.cloud_provider_zone
enable_l4_ilb_subsetting = true

network = local.automq_byoc_vpc_name
subnetwork = google_compute_subnetwork.gke_subnetwork[0].id

networking_mode = "VPC_NATIVE"

release_channel {
channel = "STABLE"
}

addons_config {
dns_cache_config {
enabled = true
}
gce_persistent_disk_csi_driver_config {
enabled = true
}
}

datapath_provider = "ADVANCED_DATAPATH"

remove_default_node_pool = true
initial_node_count = 1

# Set `deletion_protection` to `true` will ensure that one cannot
# accidentally delete this instance by use of Terraform.
deletion_protection = false
}


resource "google_tags_tag_key" "automqAssignedKey" {
parent = "projects/${var.cloud_project_id}"
short_name = "automqAssigned"
}

resource "google_tags_tag_value" "automqAssignedValue" {
parent = "tagKeys/${google_tags_tag_key.automqEnvKey.name}"
short_name = "automq"
}


resource "google_container_node_pool" "automq_gke_node_pool" {
name = "node-pool-${var.automq_byoc_env_id}"
location = var.cloud_provider_region
cluster = google_container_cluster.automq_gke_cluster.id
node_count = 1

node_config {
machine_type = "n2d-standard-4"

disk_type = "pd-ssd"
disk_size_gb = 20

workload_metadata_config {
mode = "GCE_METADATA" // GKE_METADATA for workload identity
}

# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
service_account = google_service_account.automq_byoc_sa.email
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
}

autoscaling {
total_min_node_count = 3
total_max_node_count = 9
location_policy = "BALANCED"
}

management {
auto_repair = false
auto_upgrade = true
}
}

resource "google_compute_router" "router" {
project = var.cloud_project_id
name = "nat-router-${var.automq_byoc_env_id}"
network = local.automq_byoc_vpc_name
region = var.cloud_provider_region
}

resource "google_compute_router" "vpc_router" {
name = "vpc-router-${var.automq_byoc_env_id}"
network = data.google_compute_network.vpc.id
region = var.cloud_provider_region
}

resource "google_compute_router_nat" "vpc_nat" {
name = "vpc-nat-gateway-${var.automq_byoc_env_id}"
router = google_compute_router.vpc_router.name
region = var.cloud_provider_region

nat_ip_allocate_option = "AUTO_ONLY"

source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS"

subnetwork {
name = google_compute_subnetwork.gke_subnetwork[0].name
source_ip_ranges_to_nat = [google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range]
}
}

0 comments on commit 21ec6b6

Please sign in to comment.