我对Terraform比较陌生,我目前的$雇主使用Terraform,我们在每个项目中都有init.tf
文件。
它:
- a
terraform
block, provider
块,data terraform_remote_state
块
我想知道这个文件是干什么用的。
我在构建Terraform项目的文档/指南中没有看到任何提及,例如:
- https://www.terraform.io/language/modules/develop/structure
- terrform文件夹结构
- https://www.digitalocean.com/community/tutorials/how-to-structure-a-terraform-project
- https://www.terraform-best-practices.com/code-structure
我确实看到一些(很少)提到其他人有这个文件,例如https://github.com/hashicorp/terraform/issues/21722
我在terraform代码库中没有看到任何提及:
[~/git/terraform] main ± git log -S init.tf
[~/git/terraform] main ±
我也检查了"启动并运行与地形"(第三版),没有提到init.tf
这曾经是一个惯例吗?这是怎么回事?:)
将其命名为init.tf
的人更有可能想要传达一个信息,即需要初始化terraform
您可以通过运行命令-terraform init, terraform plan
等继续工作。
规范是将文件命名为provider.tf
,尽管如何命名地形文件并不重要。它可以是whatever.tf
,只要它以。tf