@@ -15,10 +15,10 @@ locals {
1515
1616 target_folder_name = local. is_bicep_avm ? " scripts-bicep-avm" : " scripts"
1717
18- # Get a list of on-demand folders
19- on_demand_folders = local. is_bicep_iac_type ? try (local. starter_module_config . on_demand_folders , []) : []
18+ # Get a list of on-demand folders (only for classic bicep, not bicep-avm)
19+ on_demand_folders = local. is_classic_bicep ? try (local. starter_module_config . on_demand_folders , []) : []
2020
21- networking_type = local. is_classic_bicep && fileexists (" ${ var . module_folder_path } /${ var . bicep_parameters_file_path } " ) ? jsondecode (file (" ${ var . module_folder_path } /${ var . bicep_parameters_file_path } " )). NETWORK_TYPE : " "
21+ networking_type = local. is_bicep_avm ? var . network_type : (local . is_classic_bicep && fileexists (" ${ var . module_folder_path } /${ var . bicep_parameters_file_path } " ) ? jsondecode (file (" ${ var . module_folder_path } /${ var . bicep_parameters_file_path } " )). NETWORK_TYPE : " " )
2222 script_files = local. is_bicep_iac_type ? { for script_file in local . script_files_all : format (" %03d" , script_file. order ) => {
2323 name = script_file.name
2424 displayName = script_file.displayName
@@ -36,13 +36,27 @@ locals {
3636 {
3737 content = templatefile (" ${ local . deploy_script_file_directory_path } /${ deploy_script_file } " , {
3838 script_files = local.script_files
39- on_demand_folders = local.on_demand_folders
40- on_demand_folder_repository = var.on_demand_folder_repository
41- on_demand_folder_artifact_name = var.on_demand_folder_artifact_name
39+ on_demand_folders = local.is_classic_bicep ? local. on_demand_folders : []
40+ on_demand_folder_repository = local.is_classic_bicep ? var.on_demand_folder_repository : " "
41+ on_demand_folder_artifact_name = local.is_classic_bicep ? var.on_demand_folder_artifact_name : " "
4242 })
4343 }
4444 }
4545
46+ # Add parameters.json for bicep-avm
47+ parameters_json_file = local. is_bicep_avm ? {
48+ " ${local.target_folder_name}/parameters.json" = {
49+ content = templatefile (" ${ local . deploy_script_file_directory_path } /parameters.json.tftpl" , {
50+ management_group_id = local.root_parent_management_group_id
51+ subscription_id_management = try (var. subscription_ids [" management" ], var. subscription_id_management , " " )
52+ subscription_id_identity = try (var. subscription_ids [" identity" ], var. subscription_id_identity , " " )
53+ subscription_id_connectivity = try (var. subscription_ids [" connectivity" ], var. subscription_id_connectivity , " " )
54+ location = var.bootstrap_location
55+ network_type = local.networking_type
56+ })
57+ }
58+ } : {}
59+
4660 module_files = { for key , value in module . files . files : key =>
4761 {
4862 content = try (replace ((file (value. path )), " # backend \" azurerm\" {}" , (var. create_bootstrap_resources_in_azure ? " backend \" azurerm\" {}" : " backend \" local\" {}" )), " unsupported_file_type" )
@@ -52,13 +66,13 @@ locals {
5266 # Build a map of module files with types that are supported
5367 module_files_supported = { for key , value in local . module_files : key => value if value . content != " unsupported_file_type" && ! endswith (key, " -cache.json" ) && ! endswith (key, local. bicep_config_file_path ) }
5468
55- # Build a list of files to exclude from the repository based on the on-demand folders
56- excluded_module_files = distinct (flatten ([for exclusion in local . on_demand_folders :
69+ # Build a list of files to exclude from the repository based on the on-demand folders (only for classic bicep)
70+ excluded_module_files = local . is_classic_bicep ? distinct (flatten ([for exclusion in local . on_demand_folders :
5771 [for key , value in local . module_files_supported : key if startswith (key, exclusion. target )]
58- ]))
72+ ])) : []
5973
6074 # Filter out the excluded files
6175 module_files_filtered = { for key , value in local . module_files_supported : key => value if ! contains (local. excluded_module_files , key) }
6276
63- final_module_files = merge (local. module_files_filtered , local. deploy_script_files_parsed )
77+ final_module_files = merge (local. module_files_filtered , local. deploy_script_files_parsed , local . parameters_json_file )
6478}
0 commit comments