【发布时间】:2021-08-18 22:11:25
【问题描述】:
我在 terraform 中有一个 module a,它创建了一个 text 文件,我需要在另一个 module b 中使用该文本文件,我正在使用 locals 来拉取该文本文件的内容,如下所示 @ 987654325@
locals {
ports = split("\n", file("ports.txt") )
}
但是terraform 期望这个文件在开始时本身就存在,抛出如下错误
Invalid value for "path" parameter: no file exists at
path/ports.txt; this function works only with files
that are distributed as part of the configuration source code, so if this file
will be created by a resource in this configuration you must instead obtain
this result from an attribute of that resource.
我在这里缺少什么?对此的任何帮助将不胜感激。 locals 有没有 depends_on,我怎样才能做到这一点
【问题讨论】:
-
这两个模块如何使用?你有任何完整的代码来展示这个问题吗?
-
抱歉,如果这不是一个真正的答案。 Terraform 非常擅长沿着它的图表找出依赖关系 - 如果你正在写入文件系统然后读取该文件,那么你就是从图表中冲出,然后跳回。如果你可以在图表中做到这一点,你'会有更好的时间。模块a可以将信息传递给模块b而不是通过文件系统传递吗?
标签: terraform terraform-provider-azure