Skip to content

Commit

Permalink
Merge branch 'peering' into 'master'
Browse files Browse the repository at this point in the history
[#14](https://gitea.obmondo.com/EnableIT/qd2xcggwag/issues/14) fix peering to use existing subnet

See merge request kubernetes/k8id!1047
  • Loading branch information
Aman Shah committed Oct 18, 2023
2 parents 85509f9 + 934cd63 commit 4011397
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion terraform/azure/peering/peering.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@ provider "azurerm" {
features {}
}

data "azurerm_kubernetes_cluster" "k8s" {
name = var.cluster_name
resource_group_name = var.resource_group
}

resource "azurerm_virtual_network_peering" "peer1" {
name = "clustertowg"
resource_group_name = var.resource_group
virtual_network_name = var.vnet_name != null ? var.vnet_name : var.ext_vnet_name
remote_virtual_network_id = var.wg_vnet_id
allow_forwarded_traffic = var.allow_forwarded_traffic
}

resource "azurerm_virtual_network_peering" "peer2" {
name = var.peer_name
resource_group_name = var.wg_resource_group
virtual_network_name = var.wg_vnet_name
remote_virtual_network_id = var.cluster_vnet_id != null ? var.cluster_vnet_id : var.ext_cluster_vnet_id
allow_forwarded_traffic = var.allow_forwarded_traffic
}

resource "azurerm_private_dns_zone_virtual_network_link" "link_bastion_cluster" {
name = "dnslink-wg-cluster"
private_dns_zone_name = var.private_dns_zone_name
private_dns_zone_name = var.private_dns_zone_name != null ? var.private_dns_zone_name : join(".", slice(split(".", data.azurerm_kubernetes_cluster.k8s.private_fqdn), 1, length(split(".", data.azurerm_kubernetes_cluster.k8s.private_fqdn))))
resource_group_name = "MC_${var.resource_group}_${var.cluster_name}_${var.location}"
virtual_network_id = var.wg_vnet_id
}
5 changes: 5 additions & 0 deletions terraform/azure/peering/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ variable "ext_vnet_name" {
type = string
default = null
}

variable "allow_forwarded_traffic" {
type = bool
default = true
}

0 comments on commit 4011397

Please sign in to comment.