'Not a valid output for module' when using output variable with terraform

余生颓废 提交于 2019-11-29 11:30:16
ydaetskcoR

Outputs need to be passed up through each module explicitly each time.

For example if you wanted to output a variable to the screen from a module nested below another module you would need something like this:

child-module.tf

output "child_foo" {
  value = "foobar"
}

parent-module.tf

module "child" {
  source = "path/to/child"
}

output "parent_foo" {
  value = "${module.child.child_foo}"
}

main.tf

module "parent" {
  source = "path/to/parent"
}

output "main_foo" {
  value = "${module.parent.parent_foo}"
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!