Skip to content

Commit aa8a02c

Browse files
committed
add default value capability with double pipe syntax
1 parent ac0024f commit aa8a02c

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

alz/azuredevops/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ output "details" {
55
starter_module_name = var.starter_module_name
66
}
77
}
8+
9+
output "test" {
10+
value = module.file_manipulation.test
11+
}

modules/file_manipulation/locals.bicep.tf

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@ locals {
66
networking_type = local.is_bicep_iac_type ? try(local.bicep_parameters.network_type, local.bicep_parameters.networkType) : ""
77
}
88

9+
output "test" {
10+
value = local.bicep_module_files_defaults_found
11+
}
12+
13+
locals {
14+
bicep_module_files_defaults_found = distinct(flatten([for key, value in local.module_files_filtered : [
15+
for template in regexall("(\\{\\{[\\s]*.*?[\\s]*\\}\\})", value.content) :
16+
replace(replace(template[0], "{{", ""), "}}", "") if length(template) > 0 && strcontains(template[0], "||")
17+
] if endswith(key, ".bicepparam")
18+
]))
19+
20+
bicep_module_files_defaults = { for item in local.bicep_module_files_defaults_found :
21+
(split("||", item)[0]) => split("||", item)[1]
22+
}
23+
}
24+
925
locals {
1026
bicep_module_files_prepped_for_templating = { for key, value in local.module_files_filtered : key =>
1127
{
12-
content = replace(replace(replace(value.content, "$${", "$$${"), "{{", "$${"), "}}", "}")
28+
content = replace(replace(replace(replace(value.content, "/(\\|\\|[\\s]*.*?[\\s]*\\}\\})/", "}}"), "$${", "$$${"), "{{", "$${"), "}}", "}")
1329
} if endswith(key, ".bicepparam")
1430
}
1531

@@ -23,7 +39,9 @@ locals {
2339
unique_postfix = var.resource_names.unique_postfix
2440
time_stamp = var.resource_names.time_stamp
2541
time_stamp_formatted = var.resource_names.time_stamp_formatted
26-
}, local.bicep_parameters)
42+
},
43+
local.bicep_module_files_defaults,
44+
local.bicep_parameters)
2745
}
2846

2947
locals {

0 commit comments

Comments
 (0)