2015-10-06 01:08:33 +02:00
---
layout: "Template"
page_title: "Template: cloudinit_multipart"
sidebar_current: "docs-template-resource-cloudinit-config"
description: |-
2015-11-28 11:07:06 +01:00
Renders a multi-part cloud-init config from source files.
2015-10-06 01:08:33 +02:00
---
# template\_cloudinit\_config
2015-11-28 11:07:06 +01:00
Renders a multi-part cloud-init config from source files.
2015-10-06 01:08:33 +02:00
## Example Usage
```
2015-11-28 11:07:06 +01:00
# Render a part using a `template_file`
2015-10-06 01:08:33 +02:00
resource "template_file" "script" {
template = "${file("${path.module}/init.tpl")}"
vars {
consul_address = "${aws_instance.consul.private_ip}"
}
}
2015-11-28 11:07:06 +01:00
# Render a multi-part cloudinit config making use of the part
# above, and other source files
2015-10-06 01:08:33 +02:00
resource "template_cloudinit_config" "config" {
2015-11-28 11:07:06 +01:00
gzip = true
base64_encode = true
2015-10-06 01:08:33 +02:00
# Setup hello world script to be called by the cloud-config
part {
filename = "init.cfg"
content_type = "text/part-handler"
content = "${template_file.script.rendered}"
}
part {
2015-11-28 11:07:06 +01:00
content_type = "text/x-shellscript"
content = "baz"
2015-10-06 01:08:33 +02:00
}
2015-11-28 11:07:06 +01:00
part {
content_type = "text/x-shellscript"
content = "ffbaz"
}
}
2015-10-06 01:08:33 +02:00
```
## Argument Reference
The following arguments are supported:
* `gzip` - (Optional) Specify whether or not to gzip the rendered output.
* `base64_encode` - (Optional) Base64 encoding of the rendered output.
2015-11-28 11:07:06 +01:00
* `part` - (Required) One may specify this many times, this creates a fragment of the rendered cloud-init config file. The order of the parts is maintained in the configuration is maintained in the rendered template.
2015-10-06 01:08:33 +02:00
The `part` block supports:
* `filename` - (Optional) Filename to save part as.
* `content_type` - (Optional) Content type to send file as.
* `content` - (Required) Body for the part.
* `merge_type` - (Optional) Gives the ability to merge multiple blocks of cloud-config together.
## Attributes Reference
The following attributes are exported:
2015-11-28 11:07:06 +01:00
* `rendered` - The final rendered multi-part cloudinit config.