Multiple .tf files in a folder

我的梦境 提交于 2021-02-17 05:39:31

问题


I have a project that I inherited that has multiple .tf (main.tf, xyz.tf, ...) files in certain folders. When it does a source = "../<folder_name>", what order are the files applied in ? I main.tf always applied first followed by the rest ?

Note: These are different from the variables.tf and outputs.tf files.


回答1:


In Terraform 0.11, regular *.tf files were loaded in alphabetical order and then override files were applied.

When invoking any command that loads the Terraform configuration, Terraform loads all configuration files within the directory specified in alphabetical order.

...

Override files are the exception, as they're loaded after all non-override files, in alphabetical order.

In the newer Terraform 0.12, the load order of *.tf files is no longer specified. Behind the scenes (in both versions), Terraform reads all of the files in a directory and then determines a resource ordering that makes sense ignoring the order the files were actually read.

Terraform automatically processes resources in the correct order based on relationships defined between them in configuration, and so you can organize resources into source files in whatever way makes sense for your infrastructure.



来源:https://stackoverflow.com/questions/59515702/multiple-tf-files-in-a-folder

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