Hi Team,
So i am following this github repo(“learn-terraform-count-foreach/outputs.tf at master · hashicorp/learn-terraform-count-foreach · GitHub”) and i have some trouble using some outputs of for_each module.
There are 2 scenarios where i am unclear how to use
- Outputs to be mapped to a variable in next module which is declared as string
So cd is a module which is run in for_each loop and it has output name pd. bd is a variable for a different module and it is declared as string and it can’t be changed to list.
I tried
bd = module.cd.pd[0]
also
bd = module.cd[0].pd
get this error “module.cd is object with n attributes”
bd = flatten ([{ for p in sort(keys(var.pm)) :
p => module.cd[p].pd
}])
or
bd = concat( [{ for p in sort(keys(var.pm)) :
p => module.cd[p].pd
}])
get this error “The given value is not suitable for child module variable
“bd” defined at
.: string required.”
Can anyone help ?
- We have a field where we need to combine output for 2 for_each module or 1 for_each module
Error: Invalid value for module argument
PS = concat(
module.fs.cn,
module.ps.cn,
[{ for p in sort(keys(var.pm)) :
p => module.cd[p].pd
}]
)
The given value is not suitable for child module variable “pm”
defined at : all list
elements must have the same type.