@@ -4,10 +4,12 @@ locals {
44 suffix = lower (var. suffix )
55 resource_group_name = " ${ var . prefix } -rg"
66 log_analytics_name = " ${ local . prefix } -log-analytics-${ local . suffix } "
7+ storage_account_name = " ${ local . prefix } datastore${ local . suffix } "
78 virtual_network_name = " ${ local . prefix } -vnet-${ local . suffix } "
89 nat_gateway_name = " ${ local . prefix } -nat-gateway-${ local . suffix } "
910 private_endpoint_name = " ${ local . prefix } -mongodb-pe-${ local . suffix } "
10- network_security_group_name = " ${ local . prefix } -default-nsg-${ local . suffix } "
11+ webapp_subnet_nsg_name = " ${ local . prefix } -webapp-subnet-nsg-${ local . suffix } "
12+ pe_subnet_nsg_name = " ${ local . prefix } -pe-subnet-nsg-${ local . suffix } "
1113 cosmosdb_account_name = " ${ local . prefix } -mongodb-${ local . suffix } "
1214 app_service_plan_name = " ${ local . prefix } -app-service-plan-${ local . suffix } "
1315 web_app_name = " ${ local . prefix } -webapp-${ local . suffix } "
@@ -61,21 +63,33 @@ module "virtual_network" {
6163 ]
6264}
6365
64- # Create a network security group and associate it with the default subnet
65- module "network_security_group " {
66+ # Create a network security group and associate it with the webapp subnet
67+ module "webapp_subnet_network_security_group " {
6668 source = " ./modules/network_security_group"
67- name = local. network_security_group_name
69+ name = local. webapp_subnet_nsg_name
6870 resource_group_name = azurerm_resource_group. example . name
6971 location = var. location
7072 log_analytics_workspace_id = module. log_analytics_workspace . id
7173 tags = var. tags
7274 subnet_ids = {
7375 (var. webapp_subnet_name ) = module.virtual_network.subnet_ids[var.webapp_subnet_name]
7476 }
77+ }
7578
79+ # Create a network security group and associate it with the private endpoint subnet
80+ module "pe_subnet_network_security_group" {
81+ source = " ./modules/network_security_group"
82+ name = local. pe_subnet_nsg_name
83+ resource_group_name = azurerm_resource_group. example . name
84+ location = var. location
85+ log_analytics_workspace_id = module. log_analytics_workspace . id
86+ tags = var. tags
87+ subnet_ids = {
88+ (var. pe_subnet_name ) = module.virtual_network.subnet_ids[var.pe_subnet_name]
89+ }
7690}
7791
78- # Create a NAT gateway and associate it with the default subnet
92+ # Create a NAT gateway and associate it with the webapp subnet
7993module "nat_gateway" {
8094 source = " ./modules/nat_gateway"
8195 name = local. nat_gateway_name
0 commit comments