Terraform:使用文件插值从模块读取本地文件
有没有办法告诉terraform当我做类似的事情时Terraform:使用文件插值从模块读取本地文件,terraform,Terraform,有没有办法告诉terraform当我做类似的事情时 locals { file_content = "${file("somefile.txt")}" } 在模块内部,它应该读取模块中的文件? 如果文件结构如下所示: /module /main.tf <- the code above is here /somefile.txt /project /main.tf <- this uses the module from ../modul
locals {
file_content = "${file("somefile.txt")}"
}
在模块内部,它应该读取模块中的文件?
如果文件结构如下所示:
/module
/main.tf <- the code above is here
/somefile.txt
/project
/main.tf <- this uses the module from ../module
/module
/main.tf您可以使用来引用模块的路径
因此,在您的模块中,您可以使用以下内容引用它:
locals {
file_content = "${file("${path.module}/somefile.txt")}"
}
这也显示在:
> file("${path.module}/hello.txt")
Hello World