Skip to content

Commit

Permalink
clean up 1
Browse files Browse the repository at this point in the history
  • Loading branch information
raubitsj committed Sep 11, 2024
1 parent bcf8fbd commit 4d0fad6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
29 changes: 4 additions & 25 deletions modules/clickhouse/main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
resource "google_compute_subnetwork" "psc_network" {
name = "${var.clickhouse_region}-subnet"
name = "${var.namespace}-subnet-clickhouse-${var.clickhouse_region}"

ip_cidr_range = "10.20.0.0/16"
region = var.clickhouse_region
ip_cidr_range = var.clickhouse_reserved_ip_range
private_ip_google_access = true
network = var.network.id
region = var.clickhouse_region
}

resource "google_compute_address" "psc_endpoint_ip" {
# You can specify an IP address if needed.
# address = "10.148.0.2"
address_type = "INTERNAL"
name = "clickhouse-cloud-psc-${var.clickhouse_region}"
purpose = "GCE_ENDPOINT"
Expand All @@ -20,11 +18,9 @@ resource "google_compute_address" "psc_endpoint_ip" {
resource "google_compute_forwarding_rule" "clickhouse_cloud_psc" {
ip_address = google_compute_address.psc_endpoint_ip.self_link
name = "ch-cloud-${var.clickhouse_region}"
# network = var.network.id
network = var.network.id
region = var.clickhouse_region
load_balancing_scheme = ""
# service attachment
target = "https://www.googleapis.com/compute/v1/${var.clickhouse_private_endpoint_service_name}"
allow_psc_global_access = true
}
Expand Down Expand Up @@ -53,23 +49,6 @@ resource "google_dns_record_set" "psc-wildcard" {
managed_zone = google_dns_managed_zone.clickhouse_cloud_private_service_connect.name
name = "*.${var.clickhouse_region}.p.gcp.clickhouse.cloud."
type = "A"
rrdatas = [google_compute_address.psc_endpoint_ip.address]
rrdatas = [ google_compute_address.psc_endpoint_ip.address ]
ttl = 3600
}

//resource "google_compute_route" "default_to_psc" {
// name = "${var.namespace}-default-to-psc"
// network = var.network.self_link
// dest_range = google_compute_subnetwork.psc_network.ip_cidr_range
// next_hop_ilb = "YOUR_NEXT_HOP"
// priority = 1000
// tags = ["default-to-psc"]
//}

//resource "google_compute_route" "default_to_psc" {
// name = "${var.namespace}-default-to-psc-route"
// network = var.network.self_link
// dest_range = google_compute_subnetwork.psc_network.ip_cidr_range
// next_hop_peering = google_compute_network_peering.default_to_psc.self_link
// priority = 1000
//}
6 changes: 6 additions & 0 deletions modules/clickhouse/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "subnetwork" {
type = string
}

variable "clickhouse_reserved_ip_range" {
type = string
description = "Reserved IP range for ClickHouse private link"
default = "10.20.0.0/16"
}

variable "clickhouse_private_endpoint_service_name" {
type = string
description = "ClickHouse private endpoint 'Service name' (ends in -clickhouse-cloud)."
Expand Down

0 comments on commit 4d0fad6

Please sign in to comment.