Skip to content

Commit

Permalink
[CES-108] Add private endpoints to CGN Cosmos Account without alterin…
Browse files Browse the repository at this point in the history
…g DNS (#1235)
  • Loading branch information
Krusty93 authored Oct 7, 2024
1 parent 9864646 commit 84bc91b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/domains/cgn/_modules/cosmos/cosmos_account_cgn.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@ module "cosmos_account_cgn" {

tags = var.tags
}

resource "azurerm_private_endpoint" "cosno_remote_content_itn" {
name = "${var.project}-itn-cgn-cosno-pep-01"
location = "italynorth"
resource_group_name = var.resource_group_name
subnet_id = var.private_endpoint_subnet_id_itn

private_service_connection {
name = "${var.project}-itn-cgn-cosno-pep-01"
private_connection_resource_id = module.cosmos_account_cgn.id
is_manual_connection = false
subresource_names = ["Sql"]
}

tags = var.tags
}
5 changes: 5 additions & 0 deletions src/domains/cgn/_modules/cosmos/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ variable "private_endpoint_subnet_id" {
type = string
description = "Id of the subnet which has private endpoints"
}

variable "private_endpoint_subnet_id_itn" {
type = string
description = "Id of the subnet which has private endpoints"
}
11 changes: 11 additions & 0 deletions src/domains/cgn/_modules/networking/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ data "azurerm_virtual_network" "vnet_common" {
resource_group_name = local.resource_group_common
}

data "azurerm_virtual_network" "common_itn" {
name = "${var.project}-itn-common-vnet-01"
resource_group_name = local.resource_group_common_itn
}

data "azurerm_subnet" "subnet_private_endpoints" {
name = "pendpoints"
resource_group_name = data.azurerm_virtual_network.vnet_common.resource_group_name
virtual_network_name = data.azurerm_virtual_network.vnet_common.name
}

data "azurerm_subnet" "pep_snet_itn" {
name = "${var.project}-itn-pep-snet-01"
resource_group_name = data.azurerm_virtual_network.common_itn.resource_group_name
virtual_network_name = data.azurerm_virtual_network.common_itn.name
}

data "azurerm_nat_gateway" "nat_gateway" {
name = "${var.project}-natgw"
resource_group_name = local.resource_group_common
Expand Down
3 changes: 2 additions & 1 deletion src/domains/cgn/_modules/networking/locals.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
locals {
resource_group_common = "${var.project}-rg-common"
resource_group_common = "${var.project}-rg-common"
resource_group_common_itn = "${var.project}-itn-common-rg-01"
}
7 changes: 7 additions & 0 deletions src/domains/cgn/_modules/networking/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ output "subnet_pendpoints" {
}
}

output "subnet_pep_itn" {
value = {
id = data.azurerm_subnet.pep_snet_itn.id
name = data.azurerm_subnet.pep_snet_itn.name
}
}

output "subnet_redis" {
value = {
id = module.subnet_redis.id
Expand Down
3 changes: 2 additions & 1 deletion src/domains/cgn/prod/cosmos.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module "cosmos" {
secondary_location = local.secondary_location
resource_group_name = module.resource_groups.resource_group_cgn.name

private_endpoint_subnet_id = module.networking.subnet_pendpoints.id
private_endpoint_subnet_id = module.networking.subnet_pendpoints.id
private_endpoint_subnet_id_itn = module.networking.subnet_pep_itn.id

tags = local.tags
}
4 changes: 2 additions & 2 deletions src/domains/cgn/prod/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ locals {
CreatedBy = "Terraform"
Environment = "Prod"
Owner = "IO"
ManagementTeam = "IO Comunicazione"
Source = "https://github.com/pagopa/io-infra/blob/main/src/domains/cgn/prod/westeurope"
ManagementTeam = "IO Enti & Servizi"
Source = "https://github.com/pagopa/io-infra/blob/main/src/domains/cgn/prod"
}
}

0 comments on commit 84bc91b

Please sign in to comment.