cloudinit_config (Resource)

Renders a multi-part MIME configuration for use with cloud-init.

Cloud-init is a commonly-used startup configuration utility for cloud compute instances. It accepts configuration via provider-specific user data mechanisms, such as user_data for Amazon EC2 instances. Multi-part MIME is one of the data formats it accepts. For more information, see User-Data Formats in the cloud-init manual.

This is not a generalized utility for producing multi-part MIME messages. It's feature set is specialized for cloud-init multi-part MIME messages.

Example Usage

Config

resource "cloudinit_config" "foobar" {
  gzip          = false
  base64_encode = false

  part {
    filename     = "hello-script.sh"
    content_type = "text/x-shellscript"

    content = file("${path.module}/hello-script.sh")
  }

  part {
    filename     = "cloud-config.yaml"
    content_type = "text/cloud-config"

    content = file("${path.module}/cloud-config.yaml")
  }
}

hello-script.sh

#!/bin/sh
echo "Hello World! I'm starting up now at $(date -R)!"

cloud-config.yaml

#cloud-config
# See documentation for more configuration examples
# https://cloudinit.readthedocs.io/en/latest/reference/examples.html 

# Install arbitrary packages
# https://cloudinit.readthedocs.io/en/latest/reference/examples.html#install-arbitrary-packages
packages:
  - python
# Run commands on first boot
# https://cloudinit.readthedocs.io/en/latest/reference/examples.html#run-commands-on-first-boot
runcmd:
 - [ ls, -l, / ]
 - [ sh, -xc, "echo $(date) ': hello world!'" ]
 - [ sh, -c, echo "=========hello world=========" ]
 - ls -l /root

Schema

Required

Optional

Read-Only

Nested Schema for part

Required:

Optional: