Fix the tf error: Inconsistent conditional result types

The conditional statement, with tomap({}) will cause the following error under terraform 1.4.5

Error: Inconsistent conditional result types
│ 
│   on ../../../modules/net-vpc/subnets.tf line 20, in locals:
│   20:   _factory_data = var.data_folder == null ? tomap({}) : {
│   21:     for f in fileset(var.data_folder, "**/*.yaml") :
│   22:     trimsuffix(basename(f), ".yaml") => yamldecode(file("${var.data_folder}/${f}"))
│   23:   }
│     ├────────────────
│     │ var.data_folder is "data/subnets/common"
│ 
│ The false result value has the wrong type: element types must all match for conversion to map.
This commit is contained in:
jamesmao-xyz 2023-04-18 19:54:37 +10:00 committed by GitHub
parent 91a1168d1d
commit e1ebfeecad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -17,8 +17,8 @@
# tfdoc:file:description Subnet resources.
locals {
_factory_data = var.data_folder == null ? tomap({}) : {
for f in fileset(var.data_folder, "**/*.yaml") :
_factory_data = {
for f in try(fileset(var.data_folder, "**/*.yaml"), []) :
trimsuffix(basename(f), ".yaml") => yamldecode(file("${var.data_folder}/${f}"))
}
_factory_subnets = {