Add example for using cloud-config in place of file provisioners

pull/31995/head
sed-i 4 years ago
parent 73c3994455
commit 42e689376a

@ -95,6 +95,44 @@ data this way will allow faster boot times and simplify deployment by avoiding
the need for direct network access from Terraform to the new server and for
remote access credentials to be provided.
### Provisioning files using cloud-config
Under some circumstances it may be feasible to
[yamlencode](https://www.terraform.io/language/functions/yamlencode) your entire
[cloud-config](https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs)
file. In that case you could use the `write_files` section in place of file
provisioners. For example:
```hcl
data "cloudinit_config" "my_cloud_config" {
gzip = false
base64_encode = false
part {
content_type = "text/cloud-config"
filename = "cloud.conf"
content = yamlencode(
{
"write_files" : [
{
"path" : "/etc/foo.conf",
"content" : "foo contents",
},
{
"path" : "/etc/bar.conf",
"content" : file("bar.conf"),
},
{
"path" : "/etc/baz.conf",
"content" : templatefile("baz.tpl.conf", { SOME_VAR = "qux" }),
},
],
}
)
}
}
```
### Running configuration management software
As a convenience to users who are forced to use generic operating system

Loading…
Cancel
Save