Reputation: 521
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? Is main.tf always applied first followed by the rest?
Note: These are different from the variables.tf and outputs.tf
files.
Upvotes: 11
Views: 8445
Reputation: 3244
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 Terraform 0.12+ (including 1.x), the load order of *.tf
files is no longer specified. Behind the scenes Terraform reads all of the files in a directory and then determines a resource ordering that makes sense regardless of the order the files were actually read.
Terraform evaluates all of the configuration files in a module, effectively treating the entire module as a single document. Separating various blocks into different files is purely for the convenience of readers and maintainers, and has no effect on the module's behavior.
Upvotes: 15