github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/template/d/cloudinit_config.html.markdown (about) 1 --- 2 layout: "template" 3 page_title: "Template: cloudinit_multipart" 4 sidebar_current: "docs-template-datasource-cloudinit-config" 5 description: |- 6 Renders a multi-part cloud-init config from source files. 7 --- 8 9 # template\_cloudinit\_config 10 11 Renders a multi-part cloud-init config from source files. 12 13 ## Example Usage 14 15 ``` 16 # Render a part using a `template_file` 17 data "template_file" "script" { 18 template = "${file("${path.module}/init.tpl")}" 19 20 vars { 21 consul_address = "${aws_instance.consul.private_ip}" 22 } 23 } 24 25 # Render a multi-part cloudinit config making use of the part 26 # above, and other source files 27 data "template_cloudinit_config" "config" { 28 gzip = true 29 base64_encode = true 30 31 # Setup hello world script to be called by the cloud-config 32 part { 33 filename = "init.cfg" 34 content_type = "text/part-handler" 35 content = "${data.template_file.script.rendered}" 36 } 37 38 part { 39 content_type = "text/x-shellscript" 40 content = "baz" 41 } 42 43 part { 44 content_type = "text/x-shellscript" 45 content = "ffbaz" 46 } 47 } 48 49 # Start an AWS instance with the cloudinit config as user data 50 resource "aws_instance" "web" { 51 ami = "ami-d05e75b8" 52 instance_type = "t2.micro" 53 user_data = "${data.template_cloudinit_config.config.rendered}" 54 } 55 ``` 56 57 ## Argument Reference 58 59 The following arguments are supported: 60 61 * `gzip` - (Optional) Specify whether or not to gzip the rendered output. Default to `true` 62 63 * `base64_encode` - (Optional) Base64 encoding of the rendered output. Default to `true` 64 65 * `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. 66 67 The `part` block supports: 68 69 * `filename` - (Optional) Filename to save part as. 70 71 * `content_type` - (Optional) Content type to send file as. 72 73 * `content` - (Required) Body for the part. 74 75 * `merge_type` - (Optional) Gives the ability to merge multiple blocks of cloud-config together. 76 77 ## Attributes Reference 78 79 The following attributes are exported: 80 81 * `rendered` - The final rendered multi-part cloudinit config.