-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add private link configuration for clickhouse
- Loading branch information
Showing
6 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
locals { | ||
dns_name_suffix = "privatelink.azure.clickhouse.cloud" | ||
} | ||
|
||
resource "azurerm_private_endpoint" "clickhouse" { | ||
name = "${var.namespace}-clickhouse-pe" | ||
location = var.location | ||
resource_group_name = var.resource_group_name | ||
subnet_id = var.private_subnet_id | ||
custom_network_interface_name = "${var.namespace}-clickhouse-nic" | ||
|
||
private_service_connection { | ||
name = "${var.namespace}-clickhouse-pl" | ||
private_connection_resource_alias = var.clickhouse_private_endpoint_service_name | ||
is_manual_connection = true | ||
request_message = "ClickHouse Private Link" | ||
} | ||
} | ||
|
||
resource "azurerm_private_dns_zone" "clickhouse_cloud_private_link_zone" { | ||
name = "${var.clickhouse_region}.${local.dns_name_suffix}" | ||
resource_group_name = var.resource_group_name | ||
} | ||
|
||
data "azurerm_network_interface" "clickhouse_nic" { | ||
resource_group_name = var.resource_group_name | ||
name = azurerm_private_endpoint.clickhouse.network_interface[0].name | ||
} | ||
|
||
resource "azurerm_private_dns_a_record" "clickhouse_wildcard" { | ||
name = "*" | ||
zone_name = azurerm_private_dns_zone.clickhouse_cloud_private_link_zone.name | ||
resource_group_name = var.resource_group_name | ||
ttl = 300 | ||
records = [data.azurerm_network_interface.clickhouse_nic.private_ip_address] | ||
} | ||
|
||
resource "azurerm_private_dns_zone_virtual_network_link" "clickhouse_network" { | ||
name = "network-link" | ||
resource_group_name = var.resource_group_name | ||
private_dns_zone_name = azurerm_private_dns_zone.clickhouse_cloud_private_link_zone.name | ||
virtual_network_id = var.network_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
variable "namespace" { | ||
type = string | ||
description = "Friendly name prefix used for tagging and naming Azure resources." | ||
} | ||
|
||
variable "resource_group_name" { | ||
type = string | ||
description = "The name of the resource group in which to create the network." | ||
} | ||
|
||
variable "location" { | ||
type = string | ||
description = "Specifies the supported Azure location where the resource exists." | ||
} | ||
|
||
variable "network_id" { | ||
type = string | ||
description = "The virtual network id used for all resources" | ||
} | ||
|
||
variable "private_subnet_id" { | ||
type = string | ||
description = "Specifies the supported Azure subnet id where the resource exists." | ||
} | ||
|
||
variable "clickhouse_private_endpoint_service_name" { | ||
type = string | ||
description = "ClickHouse private endpoint 'Service name' (ends in .azure.privatelinkservice)." | ||
default = "" | ||
|
||
validation { | ||
condition = can(regex("\\.azure\\.privatelinkservice$", var.clickhouse_private_endpoint_service_name)) | ||
error_message = "ClickHouse Service name must end in '.azure.privatelinkservice'." | ||
} | ||
} | ||
|
||
variable "clickhouse_region" { | ||
type = string | ||
description = "ClickHouse region (eastus2, westus3, etc)." | ||
default = "" | ||
|
||
validation { | ||
condition = length(var.clickhouse_region) > 0 | ||
error_message = "Clickhouse Region should always be set if the private endpoint service name is specified." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters