diff --git a/README.md b/README.md index 4562995..b9e7c07 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ No provider. | map\_config\_local\_base\_path | Base path to local YAML configuration files of map type | `string` | `""` | no | | map\_config\_paths | Paths to YAML configuration files of map type | `list(string)` | `[]` | no | | map\_config\_remote\_base\_path | Base path to remote YAML configuration files of map type | `string` | `""` | no | +| map\_configs | List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files | `any` | `[]` | no | | name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no | | namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | | parameters | Map of parameters for interpolation within the YAML config templates | `map(string)` | `{}` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 61d1963..1ece130 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -30,6 +30,7 @@ No provider. | map\_config\_local\_base\_path | Base path to local YAML configuration files of map type | `string` | `""` | no | | map\_config\_paths | Paths to YAML configuration files of map type | `list(string)` | `[]` | no | | map\_config\_remote\_base\_path | Base path to remote YAML configuration files of map type | `string` | `""` | no | +| map\_configs | List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files | `any` | `[]` | no | | name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no | | namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | | parameters | Map of parameters for interpolation within the YAML config templates | `map(string)` | `{}` | no | diff --git a/examples/complete/config/map-configs/map-config-3.yaml b/examples/complete/config/map-configs/map-config-3.yaml new file mode 100644 index 0000000..7d1628d --- /dev/null +++ b/examples/complete/config/map-configs/map-config-3.yaml @@ -0,0 +1,4 @@ +key3: + name: name3 + param: param3 + type: type3 diff --git a/examples/complete/fixtures.tfvars b/examples/complete/fixtures.tfvars index 8c429fe..cace8cc 100644 --- a/examples/complete/fixtures.tfvars +++ b/examples/complete/fixtures.tfvars @@ -19,3 +19,35 @@ parameters = { param1 = "1" param2 = "2" } + +map_configs = [ + { + key3 = { + name = "name3_override" + param = "param3_override" + }, + key4 = { + name = "name4" + param = "param4" + type = "type4" + }, + key5 = { + name = "name5" + param = ["param5a", "param5b"] + type = "type5" + } + }, + { + key6 = { + name = "name6" + param = "param6" + type = "type6" + }, + key1 = [ + { + name = "name1_override" + param = "param1_override" + } + ] + } +] diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 6c1cd75..ce7eebf 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -9,6 +9,8 @@ module "yaml_config" { list_config_remote_base_path = var.list_config_remote_base_path list_config_paths = var.list_config_paths + map_configs = var.map_configs + parameters = var.parameters context = module.this.context diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index b13e331..9342eb6 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -45,3 +45,9 @@ variable "remote_config_selector" { description = "String to detect local vs. remote config paths" default = "://" } + +variable "map_configs" { + type = any + description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files" + default = [] +} diff --git a/examples/imports-local/main.tf b/examples/imports-local/main.tf index 6c1cd75..ce7eebf 100644 --- a/examples/imports-local/main.tf +++ b/examples/imports-local/main.tf @@ -9,6 +9,8 @@ module "yaml_config" { list_config_remote_base_path = var.list_config_remote_base_path list_config_paths = var.list_config_paths + map_configs = var.map_configs + parameters = var.parameters context = module.this.context diff --git a/examples/imports-local/variables.tf b/examples/imports-local/variables.tf index b13e331..9342eb6 100644 --- a/examples/imports-local/variables.tf +++ b/examples/imports-local/variables.tf @@ -45,3 +45,9 @@ variable "remote_config_selector" { description = "String to detect local vs. remote config paths" default = "://" } + +variable "map_configs" { + type = any + description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files" + default = [] +} diff --git a/examples/imports-remote/main.tf b/examples/imports-remote/main.tf index 6c1cd75..ce7eebf 100644 --- a/examples/imports-remote/main.tf +++ b/examples/imports-remote/main.tf @@ -9,6 +9,8 @@ module "yaml_config" { list_config_remote_base_path = var.list_config_remote_base_path list_config_paths = var.list_config_paths + map_configs = var.map_configs + parameters = var.parameters context = module.this.context diff --git a/examples/imports-remote/variables.tf b/examples/imports-remote/variables.tf index b13e331..9342eb6 100644 --- a/examples/imports-remote/variables.tf +++ b/examples/imports-remote/variables.tf @@ -45,3 +45,9 @@ variable "remote_config_selector" { description = "String to detect local vs. remote config paths" default = "://" } + +variable "map_configs" { + type = any + description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files" + default = [] +} diff --git a/main.tf b/main.tf index 0afdcdf..7d047d4 100644 --- a/main.tf +++ b/main.tf @@ -150,18 +150,21 @@ module "yaml_config_10" { module "maps_deepmerge" { source = "./modules/deepmerge" - maps = [ - module.yaml_config_10.map_configs, - module.yaml_config_9.map_configs, - module.yaml_config_8.map_configs, - module.yaml_config_7.map_configs, - module.yaml_config_6.map_configs, - module.yaml_config_5.map_configs, - module.yaml_config_4.map_configs, - module.yaml_config_3.map_configs, - module.yaml_config_2.map_configs, - module.yaml_config_1.map_configs - ] + maps = concat( + [ + module.yaml_config_10.map_configs, + module.yaml_config_9.map_configs, + module.yaml_config_8.map_configs, + module.yaml_config_7.map_configs, + module.yaml_config_6.map_configs, + module.yaml_config_5.map_configs, + module.yaml_config_4.map_configs, + module.yaml_config_3.map_configs, + module.yaml_config_2.map_configs, + module.yaml_config_1.map_configs + ], + var.map_configs + ) } locals { diff --git a/variables.tf b/variables.tf index b13e331..9342eb6 100644 --- a/variables.tf +++ b/variables.tf @@ -45,3 +45,9 @@ variable "remote_config_selector" { description = "String to detect local vs. remote config paths" default = "://" } + +variable "map_configs" { + type = any + description = "List of existing configurations of map type. Deep-merging of the existing map configs takes precedence over the map configs loaded from YAML files" + default = [] +}