Commit Graph

3 Commits

Author SHA1 Message Date
Martin Atkins eaac9fbca3 provider/template: template_dir explicitly create dest dir
Previously we were letting it get implicitly created as part of making
the structure for copying in each file, but that isn't sufficient if the
source directory is empty.

By explicitly creating the directory first we ensure that it will complete
successfully even in the case of an empty directory.
2017-04-25 10:48:26 -07:00
Martin Atkins eda2550074 provider/template: template_dir: don't crash if source dir nonexistent
When an error is passed, the FileInfo can be nil, which was previously
causing a crash on trying to evaluate f.IsDir(). By checking for an error
first we avoid this crash.
2017-04-25 10:48:26 -07:00
Quentin Machu f721608e4e provider/template: Add a 'dir' resource to template entire directories
When TerraForm is used to configure and deploy infrastructure
applications that require dozens templated files, such as Kubernetes, it
becomes extremely burdensome to template them individually: each of them
requires a data source block as well as an upload/export (file
provisioner, AWS S3, ...).

Instead, this commit introduces a mean to template an entire folder of
files (recursively), that can then be treated as a whole by any provider
or provisioner that support directory inputs (such as the
file provisioner, the archive provider, ...).

This does not intend to make TerraForm a full-fledged templating system
as the templating grammar and capabilities are left unchanged. This only
aims at improving the user-experience of the existing templating
provider by significantly reducing the overhead when several files are
to be generated - without forcing the users to rely on external tools
when these templates stay simple and that their generation in TerraForm
is justified.
2017-04-25 10:48:26 -07:00