Packer
File Data Source
Official
Type: file
The file
data source writes the specified contents to a file, creating it in the process if it doesn't exist.
This is particularly useful if you have a file to dynamically generate (with templatefile
for example), and the component you
rely on only accepts files, and not the generated string.
Using this data source, you can use those functions and have the output written to a temporary file that you can
reference in a component afterwards.
Note: being a datasource, the created file is not wiped-out after the build finishes. By default Packer will output
the file into the system's TEMPDIR
(typically /tmp
on UNIX systems, or `on Windows).
You can also change this by specifying a
destination` for the data source.
Basic Example
data "file" "example" {
contents = "this is an example"
}
Configuration Reference
Not Required:
contents
(string) - The contents of the file to createThis is useful especially for files that involve templating so that Packer can dynamically create files and expose them for later importing as attributes in another entity.
If no contents are specified, the resulting file will be empty.
destination
(string) - The file or directory to write the contents to.
Datasource outputs
The outputs for this datasource are as follows:
path
(string) - The path of the file created