@@ -5,31 +5,29 @@ locals {
5
5
] : []
6
6
7
7
# Terraform maps from local YAML configuration templates
8
- local_map_configs = merge (
9
- flatten (
10
- [
11
- for path in local . local_map_config_paths : [
12
- for f in fileset (var. map_config_local_base_path , path) : {
13
- for k , v in yamldecode (templatefile (format (" %s/%s" , var. map_config_local_base_path , f), var. parameters )) : k => v
14
- }
15
- ]
8
+ local_map_configs = flatten (
9
+ [
10
+ for path in local . local_map_config_paths : [
11
+ for f in fileset (var. map_config_local_base_path , path) : {
12
+ for k , v in yamldecode (templatefile (format (" %s/%s" , var. map_config_local_base_path , f), var. parameters )) : k => v
13
+ }
16
14
]
17
- )
18
- ... )
15
+ ]
16
+ )
19
17
20
18
# Remote YAML paths with configs of type map
21
19
remote_map_config_paths = module. this . enabled ? [
22
20
for path in var . map_config_paths : path if replace (path, var. remote_config_selector , " " ) != path
23
21
] : []
24
22
25
23
# Terraform maps from remote YAML configuration templates
26
- remote_map_configs = merge (
24
+ remote_map_configs = flatten (
27
25
[
28
26
for path in local . remote_map_config_paths : {
29
27
for k , v in yamldecode (data. template_file . remote_config [base64encode (path)]. rendered ) : k => v
30
28
}
31
29
]
32
- ... )
30
+ )
33
31
34
32
# Local YAML paths with configs of type list
35
33
local_list_config_paths = module. this . enabled ? [
@@ -67,6 +65,11 @@ locals {
67
65
} : {}
68
66
}
69
67
68
+ module "all_map_configs" {
69
+ source = " ../deepmerge"
70
+ maps = concat ([{}], local. remote_map_configs , local. local_map_configs )
71
+ }
72
+
70
73
# Download all remote configs
71
74
data "http" "remote_config" {
72
75
for_each = module. this . enabled ? local. all_remote_config_paths_map : {}
@@ -81,20 +84,17 @@ data "template_file" "remote_config" {
81
84
}
82
85
83
86
locals {
84
- # Final map configs
85
- all_map_configs = merge ({}, local. local_map_configs , local. remote_map_configs )
86
-
87
87
# Final list configs
88
88
all_list_configs = concat ([], local. local_list_configs , local. remote_list_configs )
89
89
90
90
# Imports from local map configs
91
91
local_map_imports = [
92
- for import in lookup (merge ({}, local. local_map_configs ), " import" , []) : format (" %s.yaml" , import)
92
+ for import in lookup (merge ({}, local. local_map_configs ... ), " import" , []) : format (" %s.yaml" , import)
93
93
]
94
94
95
95
# Imports from remote map configs
96
96
remote_map_imports = [
97
- for import in lookup (merge ({}, local. remote_map_configs ), " import" , []) : format (" %s/%s.yaml" , var. map_config_remote_base_path , import)
97
+ for import in lookup (merge ({}, local. remote_map_configs ... ), " import" , []) : format (" %s/%s.yaml" , var. map_config_remote_base_path , import)
98
98
]
99
99
100
100
# Combined imports from local and remote map configs
0 commit comments