Filesystem
When building IaC solutions using Terraform, there are many situations where we need to either use existing files or create new ones. In this section, we’ll look at the utility providers that enable more advanced scenarios that move beyond the file
and templatefile
functions and when we should use the providers versus using the functions.
Reading and writing local files
There are many situations when reading or writing files can be very useful to simplify how Terraform integrates with other tools by creating configuration files, scripts, or any other artifact required for your infrastructure deployment. To produce the desired output, you can define the content using templated files, input variables, or other expressions within your HCL code.
Terraform has a utility provider called local
that provides this functionality. This provider has two resources and two data sources named local_file
and local_sensitive_file
.
Why not just use the function? Functions...