Skip to content

Commit

Permalink
fix:change in count condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupalgw committed Feb 27, 2024
1 parent 1b20bce commit 7f7d249
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 57 deletions.
38 changes: 21 additions & 17 deletions example/point-to-site-with-ad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,38 @@ module "resource_group" {
## Virtual Network in which vpn subnet(Gateway Subnet) will be created.
##-----------------------------------------------------------------------------
module "vnet" {
source = "clouddrove/vnet/azure"
version = "1.0.3"
name = local.name
environment = local.environment
source = "clouddrove/vnet/azure"
version = "1.0.4"

name = "app"
environment = "test"
label_order = ["name", "environment"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
address_spaces = ["10.30.0.0/16"]
}

##-----------------------------------------------------------------------------
## Subnet module call.
## Name specific subnet for vpn will be created.
##-----------------------------------------------------------------------------

module "subnet" {
source = "clouddrove/subnet/azure"
version = "1.0.2"
name = local.name
environment = local.environment
source = "clouddrove/subnet/azure"
version = "1.1.0"

name = "app"
environment = "test"
label_order = ["name", "environment"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_name = join("", module.vnet.vnet_name)
virtual_network_name = module.vnet.vnet_name

#subnet
specific_name_subnet = true
specific_subnet_names = "GatewaySubnet"
subnet_prefixes = ["10.0.1.0/24"]
subnet_names = ["default"]
subnet_prefixes = ["10.30.0.0/20"]

# route_table
enable_route_table = false
routes = [
{
name = "rt-test"
Expand All @@ -61,7 +66,6 @@ module "subnet" {
}
]
}

##-----------------------------------------------------------------------------
## VPN module call.
## Following module will deploy point to site vpn in azure infratsructure.
Expand All @@ -78,9 +82,9 @@ module "vpn" {
address_space = "172.16.200.0/24"
vpn_client_protocols = ["OpenVPN"]
vpn_auth_types = ["AAD"]
aad_tenant = "https://login.microsoftonline.com/bcffb719XXXXXXXXXXXX7ebfb2f7bdd"
aad_tenant = "https://login.microsoftonline.com/<subscription_id>"
aad_audience = "41b23e61-6c1e-4545-b367-cd054e0ed4b4"
aad_issuer = "https://sts.windows.net/bcffb719XXXXXXXXXXXX7ebfb2f7bdd/"
aad_issuer = "https://sts.windows.net/<subscription_id>/"
}
#### enable diagnostic setting
diagnostic_setting_enable = false
Expand Down
2 changes: 1 addition & 1 deletion example/point-to-site-with-ad/output.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "vpn_gw_id" {
value = join("", module.vpn.*.vpn_gw_id)
value = module.vpn.vpn_gw_id
description = "The ID of the Virtual Network Gateway."
}

34 changes: 20 additions & 14 deletions example/point-to-site-with-certificate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,40 @@ module "resource_group" {
## Virtual Network module call.
## Virtual Network in which vpn subnet(Gateway Subnet) will be created.
##-----------------------------------------------------------------------------

module "vnet" {
source = "clouddrove/vnet/azure"
version = "1.0.3"
name = local.name
environment = local.environment
source = "clouddrove/vnet/azure"
version = "1.0.4"

name = "app"
environment = "test"
label_order = ["name", "environment"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
address_spaces = ["10.30.0.0/16"]
}


##-----------------------------------------------------------------------------
## Subnet module call.
## Name specific subnet for vpn will be created.
##-----------------------------------------------------------------------------
module "subnet" {
source = "clouddrove/subnet/azure"
version = "1.0.2"
name = local.name
environment = local.environment
source = "clouddrove/subnet/azure"
version = "1.1.0"

name = "app"
environment = "test"
label_order = ["name", "environment"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_name = join("", module.vnet.vnet_name)
virtual_network_name = module.vnet.vnet_name

#subnet
specific_name_subnet = true
specific_subnet_names = "GatewaySubnet"
subnet_prefixes = ["10.0.1.0/24"]
subnet_names = ["default"]
subnet_prefixes = ["10.30.0.0/20"]

# route_table
enable_route_table = false
routes = [
{
name = "rt-test"
Expand Down
2 changes: 1 addition & 1 deletion example/point-to-site-with-certificate/output.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "vpn_gw_id" {
value = join("", module.vpn.*.vpn_gw_id_certificate)
value = module.vpn.vpn_gw_id_certificate
description = "The ID of the Virtual Network Gateway."
}

33 changes: 19 additions & 14 deletions example/site-to-site/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,38 @@ module "resource_group" {
## Virtual Network in which vpn subnet(Gateway Subnet) will be created.
##-----------------------------------------------------------------------------
module "vnet" {
source = "clouddrove/vnet/azure"
version = "1.0.3"
name = local.name
environment = local.environment
source = "clouddrove/vnet/azure"
version = "1.0.4"

name = "app"
environment = "test"
label_order = ["name", "environment"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
address_spaces = ["10.30.0.0/16"]
}


##-----------------------------------------------------------------------------
## Subnet module call.
## Name specific subnet for vpn will be created.
##-----------------------------------------------------------------------------
module "subnet" {
source = "clouddrove/subnet/azure"
version = "1.0.2"
name = local.name
environment = local.environment
source = "clouddrove/subnet/azure"
version = "1.1.0"

name = "app"
environment = "test"
label_order = ["name", "environment"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_name = join("", module.vnet.vnet_name)
virtual_network_name = module.vnet.vnet_name

#subnet
specific_name_subnet = true
specific_subnet_names = "GatewaySubnet"
subnet_prefixes = ["10.0.1.0/24"]
subnet_names = ["default"]
subnet_prefixes = ["10.30.0.0/20"]

# route_table
enable_route_table = false
routes = [
{
name = "rt-test"
Expand Down
6 changes: 3 additions & 3 deletions example/site-to-site/output.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
output "vpn_gw_id" {
value = join("", module.vpn.*.vpn_gw_id)
value = module.vpn.vpn_gw_id
description = "The ID of the Virtual Network Gateway."
}
output "local_network_gw_id" {
value = join("", module.vpn.*.local_network_gw_id)
value = module.vpn.local_network_gw_id
description = "The ID of the Local Network Gateway."
}

output "local_network_gw_connection_id" {
value = join("", module.vpn.*.local_network_gw_connection_id)
value = module.vpn.local_network_gw_connection_id
description = "The ID of the Virtual Network Gateway Connection."
}
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ resource "azurerm_local_network_gateway" "localgw" {
## Virtual Network Gateway Connection
##-----------------------------------------------------------------------------
resource "azurerm_virtual_network_gateway_connection" "az-hub-onprem" {
count = var.enable && var.gateway_connection_type == "ExpressRoute" ? 1 : length(var.local_networks)
count = var.enable && var.gateway_connection_type == "ExpressRoute" ? length(var.local_networks) : 0
name = var.gateway_connection_type == "ExpressRoute" ? "localgw-expressroute-connection" : "localgw-connection-${var.local_networks[count.index].local_gw_name}"
resource_group_name = data.azurerm_resource_group.rg.name
location = data.azurerm_resource_group.rg.location
type = var.gateway_connection_type
virtual_network_gateway_id = var.sts_vpn == true ? join("", azurerm_virtual_network_gateway.vpngw.*.id) : join("", azurerm_virtual_network_gateway.vpngw2.*.id)
local_network_gateway_id = var.gateway_connection_type != "ExpressRoute" ? azurerm_local_network_gateway.localgw[count.index].id : null
virtual_network_gateway_id = var.sts_vpn == true ? join("", azurerm_virtual_network_gateway.vpngw[0].id) : join("", azurerm_virtual_network_gateway.vpngw2[0].id)
local_network_gateway_id = var.gateway_connection_type != "ExpressRoute" && length(azurerm_local_network_gateway.localgw) > 0 ? azurerm_local_network_gateway.localgw[0].id : null
express_route_circuit_id = var.gateway_connection_type == "ExpressRoute" ? var.express_route_circuit_id : null
peer_virtual_network_gateway_id = var.gateway_connection_type == "Vnet2Vnet" ? var.peer_virtual_network_gateway_id : null
shared_key = var.gateway_connection_type != "ExpressRoute" ? var.local_networks[count.index].shared_key : null
Expand Down
8 changes: 4 additions & 4 deletions output.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
output "vpn_gw_id" {
value = join("", azurerm_virtual_network_gateway.vpngw.*.id)
value = try( azurerm_virtual_network_gateway.vpngw[0].id, null)
description = "The ID of the Virtual Network Gateway."
}

output "vpn_gw_id_certificate" {
value = join("", azurerm_virtual_network_gateway.vpngw2.*.id)
value = try( azurerm_virtual_network_gateway.vpngw2[0].id, null)
description = "The ID of the Virtual Network Gateway."
}

output "local_network_gw_id" {
value = join("", azurerm_local_network_gateway.localgw.*.id)
value = try(azurerm_local_network_gateway.localgw[*].id, null)
description = "The ID of the Local Network Gateway."
}
output "local_network_gw_connection_id" {
value = join("", azurerm_virtual_network_gateway_connection.az-hub-onprem.*.id)
value = try( azurerm_virtual_network_gateway_connection.az-hub-onprem[*].id, null)
description = "The ID of the Virtual Network Gateway Connection."
}

0 comments on commit 7f7d249

Please sign in to comment.