@@ -11,10 +11,11 @@ locals {
1111 blob_storage_private_endpoint_name = " ${ local . prefix } -blob-storage-pe-${ local . suffix } "
1212 queue_storage_private_endpoint_name = " ${ local . prefix } -queue-storage-pe-${ local . suffix } "
1313 table_storage_private_endpoint_name = " ${ local . prefix } -table-storage-pe-${ local . suffix } "
14- network_security_group_name = " ${ local . prefix } -default-nsg-${ local . suffix } "
14+ func_subnet_nsg_name = " ${ local . prefix } -func-subnet-nsg-${ local . suffix } "
15+ pe_subnet_nsg_name = " ${ local . prefix } -pe-subnet-nsg-${ local . suffix } "
1516 cosmosdb_account_name = " ${ local . prefix } -mongodb-${ local . suffix } "
1617 service_bus_namespace_name = " ${ local . prefix } -service-bus-${ local . suffix } "
17- app_service_plan_name = " ${ local . prefix } -app-service- plan-${ local . suffix } "
18+ app_service_plan_name = " ${ local . prefix } -plan-${ local . suffix } "
1819 function_app_name = " ${ local . prefix } -func-${ local . suffix } "
1920 application_insights_name = " ${ local . prefix } -func-${ local . suffix } "
2021 managed_identity_name = " ${ local . prefix } -identity-${ local . suffix } "
@@ -53,8 +54,8 @@ module "virtual_network" {
5354
5455 subnets = [
5556 {
56- name : var.webapp_subnet_name
57- address_prefixes : var.webapp_subnet_address_prefix
57+ name : var.func_subnet_name
58+ address_prefixes : var.func_subnet_address_prefix
5859 private_endpoint_network_policies : " Enabled"
5960 private_link_service_network_policies_enabled : false
6061 delegation : " Microsoft.Web/serverFarms"
@@ -64,24 +65,34 @@ module "virtual_network" {
6465 address_prefixes : var.pe_subnet_address_prefix
6566 private_endpoint_network_policies : " Enabled"
6667 private_link_service_network_policies_enabled : false
67- delegation : null
6868 }
6969 ]
7070}
7171
72- # Create a network security group and associate it with both subnets
73- module "network_security_group " {
72+ # Create a network security group and associate it with the function app subnet
73+ module "func_subnet_network_security_group " {
7474 source = " ./modules/network_security_group"
75- name = local. network_security_group_name
75+ name = local. func_subnet_nsg_name
7676 resource_group_name = azurerm_resource_group. example . name
7777 location = var. location
7878 log_analytics_workspace_id = module. log_analytics_workspace . id
7979 tags = var. tags
8080 subnet_ids = {
81- (var. webapp_subnet_name ) = module.virtual_network.subnet_ids[var.webapp_subnet_name]
82- (var. pe_subnet_name ) = module.virtual_network.subnet_ids[var.pe_subnet_name]
81+ (var. func_subnet_name ) = module.virtual_network.subnet_ids[var.func_subnet_name]
8382 }
83+ }
8484
85+ # Create a network security group and associate it with the private endpoint subnet
86+ module "pe_subnet_network_security_group" {
87+ source = " ./modules/network_security_group"
88+ name = local. pe_subnet_nsg_name
89+ resource_group_name = azurerm_resource_group. example . name
90+ location = var. location
91+ log_analytics_workspace_id = module. log_analytics_workspace . id
92+ tags = var. tags
93+ subnet_ids = {
94+ (var. pe_subnet_name ) = module.virtual_network.subnet_ids[var.pe_subnet_name]
95+ }
8596}
8697
8798# Create a NAT gateway and associate it with the default subnet
@@ -94,7 +105,7 @@ module "nat_gateway" {
94105 idle_timeout_in_minutes = var. nat_gateway_idle_timeout_in_minutes
95106 zones = var. nat_gateway_zones
96107 subnet_ids = {
97- (var. webapp_subnet_name ) = module.virtual_network.subnet_ids[var.webapp_subnet_name ]
108+ (var. func_subnet_name ) = module.virtual_network.subnet_ids[var.func_subnet_name ]
98109 }
99110 tags = var. tags
100111}
@@ -306,7 +317,7 @@ module "function_app" {
306317 storage_account_name = module. storage_account . name
307318 storage_account_access_key = module. storage_account . primary_access_key
308319 https_only = var. https_only
309- virtual_network_subnet_id = module. virtual_network . subnet_ids [var . webapp_subnet_name ]
320+ virtual_network_subnet_id = module. virtual_network . subnet_ids [var . func_subnet_name ]
310321 vnet_route_all_enabled = true
311322 public_network_access_enabled = var. public_network_access_enabled
312323 always_on = var. always_on
0 commit comments