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" {
2- name = " mongodb-atlas-fabric-resourceGroup"
9+ name = " mongodb-atlas-fabric-resourceGroup- ${ random_string . random_suffix . result } "
310 location = var. azure_region
411 tags = {
512 owner = var.owner_tag
@@ -10,7 +17,7 @@ resource "azurerm_resource_group" "mongodb-atlas-fabric-resourceGroup" {
1017}
1118
1219resource "azurerm_virtual_network" "mongodb-atlas-fabric-vNet" {
13- name = " mongodb-atlas-fabric-vNet"
20+ name = " mongodb-atlas-fabric-vNet- ${ random_string . random_suffix . result } "
1421 location = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . location
1522 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
1623 address_space = [" 10.0.0.0/16" ]
@@ -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,8 @@ 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" {
126- # name = "mongodbatlasfabricvault3"
127- name = coalesce (var. azure_vault_name , " vault-${ random_string . azurerm_key_vault_name . result } " )
125+ name = coalesce (var. azure_vault_name , " vault-${ random_string . random_suffix . result } " )
128126 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
129127 sku_name = var. azure_vault_sku_name
130128 tenant_id = data. azuread_client_config . current . tenant_id
@@ -163,21 +161,21 @@ resource "azurerm_key_vault" "mongodb-atlas-fabric-mirrordb-vault" {
163161}
164162
165163resource "azuread_application_registration" "mongodb-atlas-fabric-mirrordb-integration" {
166- display_name = " mongodb-atlas-fabric-mirrordb-integration"
164+ display_name = " mongodb-atlas-fabric-mirrordb-integration- ${ random_string . random_suffix . result } "
167165}
168166
169167resource "azuread_application_password" "mongodb-atlas-fabric-mirrordb-integration-secret" {
170168 application_id = azuread_application_registration. mongodb-atlas-fabric-mirrordb-integration . id
171169}
172170
173171resource "azurerm_key_vault_secret" "mongodb-atlas-fabric-mirrordb-integration-secretValue" {
174- name = " mongodb-atlas-fabric-app-secret-v2"
172+ name = " mongodb-atlas-fabric-app-secret-v2- ${ random_string . random_suffix . result } "
175173 value = azuread_application_password. mongodb-atlas-fabric-mirrordb-integration-secret . value
176174 key_vault_id = azurerm_key_vault. mongodb-atlas-fabric-mirrordb-vault . id
177175}
178176
179177resource "azurerm_private_endpoint" "mongodb-atlas-fabric-mirrordb-integration-privateEndpoint" {
180- name = " ${ var . project_name } -private-endpoint"
178+ name = " ${ var . project_name } -private-endpoint- ${ random_string . random_suffix . result } "
181179 location = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . location
182180 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
183181 subnet_id = azurerm_subnet. mongodb-atlas-fabric-PrivateLinkSubnet [0 ]. id
@@ -200,11 +198,10 @@ resource "azurerm_private_endpoint" "mongodb-atlas-fabric-mirrordb-integration-p
200198
201199# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app
202200resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-webapp" {
203- name = " mongodbatlasfabricmirrordbsynch"
201+ name = " mongodbatlasfabricmirrordbsynch- ${ random_string . random_suffix . result } "
204202 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
205203 location = azurerm_service_plan. mongodb-atlas-fabric-service-plan [0 ]. location
206204 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
208205 site_config {
209206 application_stack {
210207 python_version = " 3.12"
@@ -215,7 +212,7 @@ resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-weba
215212 }
216213 app_settings = {
217214 " 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 } @" )
215+ " 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 } @" )
219216 " MONGO_DB_NAME" = var.mongodbatlas_dbName
220217 " MONGO_COLLECTION" = var.mongodbatlas_collectionName
221218 " LZ_URL" = replace (fabric_mirrored_database. mongodb-atlas-mirrored-database . properties . onelake_tables_path ," /Tables" ," /Files/LandingZone/" )
@@ -239,7 +236,7 @@ resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-weba
239236
240237resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-simple-webapp" {
241238 count = try (var. deployPrivateEnvironment ? 0 : 1 , 0 )
242- name = " mongodbatlasfabricmirrordbsynch"
239+ name = " mongodbatlasfabricmirrordbsynch- ${ random_string . random_suffix . result } "
243240 resource_group_name = azurerm_resource_group. mongodb-atlas-fabric-resourceGroup . name
244241 location = azurerm_service_plan. mongodb-atlas-fabric-service-simple-plan [0 ]. location
245242 service_plan_id = azurerm_service_plan. mongodb-atlas-fabric-service-simple-plan [0 ]. id
@@ -254,7 +251,7 @@ resource "azurerm_linux_web_app" "mongodb-atlas-fabric-mirrordb-integration-simp
254251 }
255252 app_settings = {
256253 " 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 } @" )
254+ " 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 } @" )
258255 " MONGO_DB_NAME" = var.mongodbatlas_dbName
259256 " MONGO_COLLECTION" = var.mongodbatlas_collectionName
260257 " LZ_URL" = replace (fabric_mirrored_database. mongodb-atlas-mirrored-database . properties . onelake_tables_path ," /Tables" ," /Files/LandingZone/" )
0 commit comments