Quantcast
Channel: Terraform - HashiCorp Discuss
Viewing all articles
Browse latest Browse all 11445

How to use outputs for for_each module

$
0
0

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

  1. 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 ?

  1. 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.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 11445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>