1+ resource "random_string" "random_suffix" {
2+ length = 5
3+ lower = true
4+ numeric = true
5+ special = false
6+ upper = false
7+ }
18resource "azurerm_resource_group" "mongodb-atlas-fabric-resourceGroup" {
29 name = " mongodb-atlas-fabric-resourceGroup"
310 location = var. azure_region
@@ -67,7 +74,7 @@ resource "azurerm_subnet" "mongodb-atlas-fabric-webAppSubnet" {
6774}
6875
6976resource "azurerm_app_service_environment_v3" "mongodb-atlas-fabric-appServiceEnv" {
70- name = " mongodb-atlas-fabric-asev3"
77+ name = " mongodb-atlas-fabric-asev3- ${ random_string . random_suffix . result } "
7178 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
7279 subnet_id = azurerm_subnet. mongodb-atlas-fabric-subnet1 [0 ]. id
7380 tags = {
@@ -81,7 +88,7 @@ resource "azurerm_app_service_environment_v3" "mongodb-atlas-fabric-appServiceEn
8188}
8289// Service plan for App Service Environment and Private Endpoint deployment
8390resource "azurerm_service_plan" "mongodb-atlas-fabric-service-plan" {
84- name = " mongodb-atlas-fabric-service-plan"
91+ name = " mongodb-atlas-fabric-service-plan- ${ random_string . random_suffix . result } "
8592 location = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . location
8693 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
8794 os_type = " Linux"
@@ -99,7 +106,7 @@ resource "azurerm_service_plan" "mongodb-atlas-fabric-service-plan" {
99106
100107// Service plan for simple deployment without private endpoint
101108resource "azurerm_service_plan" "mongodb-atlas-fabric-service-simple-plan" {
102- name = " mongodb-atlas-fabric-service-plan"
109+ name = " mongodb-atlas-fabric-service-plan- ${ random_string . random_suffix . result } "
103110 location = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . location
104111 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
105112 os_type = " Linux"
@@ -114,17 +121,9 @@ resource "azurerm_service_plan" "mongodb-atlas-fabric-service-simple-plan" {
114121 count = try (var. deployPrivateEnvironment ? 0 : 1 , 0 )
115122}
116123
117- resource "random_string" "azurerm_key_vault_name" {
118- length = 13
119- lower = true
120- numeric = false
121- special = false
122- upper = false
123- }
124-
125124resource "azurerm_key_vault" "mongodb-atlas-fabric-mirrordb-vault" {
126125 # name = "mongodbatlasfabricvault3"
127- name = coalesce (var. azure_vault_name , " vault-${ random_string . azurerm_key_vault_name . result } " )
126+ name = coalesce (var. azure_vault_name , " vault-${ random_string . random_suffix . result } " )
128127 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
129128 sku_name = var. azure_vault_sku_name
130129 tenant_id = data. azuread_client_config . current . tenant_id
@@ -204,7 +203,6 @@ resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-weba
204203 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
205204 location = azurerm_service_plan. mongodb-atlas-fabric-service-plan [0 ]. location
206205 service_plan_id = azurerm_service_plan. mongodb-atlas-fabric-service-plan [0 ]. id
207- # virtual_network_subnet_id = azurerm_subnet.mongodb-atlas-fabric-webAppSubnet.id
208206 site_config {
209207 application_stack {
210208 python_version = " 3.12"
@@ -215,7 +213,7 @@ resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-weba
215213 }
216214 app_settings = {
217215 " APP_LOG_LEVEL" = var.applicationLogLevel
218- " MONGO_CONN_STR" = replace (data. mongodbatlas_advanced_cluster . mongodb-atlas-fabric-integration-connectData . connection_strings [0 ]. private_endpoint [0 ]. srv_connection_string ," mongodb+srv://" ," mongodb+srv://${ var . mongodbatlas_userpass } @" )
216+ " MONGO_CONN_STR" = replace (data. mongodbatlas_advanced_cluster . mongodb-atlas-fabric-integration-connectData [ 0 ] . connection_strings [0 ]. private_endpoint [0 ]. srv_connection_string ," mongodb+srv://" ," mongodb+srv://${ var . mongodbatlas_userpass } @" )
219217 " MONGO_DB_NAME" = var.mongodbatlas_dbName
220218 " MONGO_COLLECTION" = var.mongodbatlas_collectionName
221219 " LZ_URL" = replace (fabric_mirrored_database. mongodb-atlas-mirrored-database . properties . onelake_tables_path ," /Tables" ," /Files/LandingZone/" )
@@ -254,7 +252,7 @@ resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-simp
254252 }
255253 app_settings = {
256254 " APP_LOG_LEVEL" = var.applicationLogLevel
257- " MONGO_CONN_STR" = replace (data. mongodbatlas_advanced_cluster . mongodb-atlas-fabric-integration-connectData . connection_strings [0 ]. standard_srv ," mongodb+srv://" ," mongodb+srv://${ var . mongodbatlas_userpass } @" )
255+ " MONGO_CONN_STR" = replace (data. mongodbatlas_advanced_cluster . mongodb-atlas-fabric-integration-connectData-noEndpoint . connection_strings [0 ]. standard_srv ," mongodb+srv://" ," mongodb+srv://${ var . mongodbatlas_userpass } @" )
258256 " MONGO_DB_NAME" = var.mongodbatlas_dbName
259257 " MONGO_COLLECTION" = var.mongodbatlas_collectionName
260258 " LZ_URL" = replace (fabric_mirrored_database. mongodb-atlas-mirrored-database . properties . onelake_tables_path ," /Tables" ," /Files/LandingZone/" )
@@ -291,4 +289,4 @@ resource "azurerm_app_service_source_control" "mongodb-atlas-fabric-mirrordb-int
291289 depends_on = [ azurerm_linux_web_app . mongodb-atlas-fabric-mirrordb-integration-simple-webapp [0 ] ]
292290 //
293291 count = try (var. deployPrivateEnvironment ? 0 : 1 , 0 )
294- }
292+ }
0 commit comments