Terraform provider for rendering cloud-init configurations.
This provider is intended to replace the template provider. General templating can now be achieved through the templatefile
function, without creating a separate data resource.
The cloud-init Terraform provider exposes the cloudinit_config
data source, previously available as the template_cloudinit_config
resource in the template provider.
Requirements
- Terraform 0.10.x
- Go 1.12 (to build the provider plugin)
Using the provider
The cloudinit_config
data source renders cloud-init config given in HCL form to the MIME-multipart form required by cloud-init.
Example configuration:
data "cloudinit_config" "foo" {
gzip = false
base64_encode = false
part {
content_type = "text/x-shellscript"
content = "baz"
}
}
This renders to:
Content-Type: multipart/mixed; boundary=\"MIMEBOUNDARY\"\nMIME-Version: 1.0\r\n\r\n--MIMEBOUNDARY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: text/x-shellscript\r\nMime-Version: 1.0\r\n\r\nbaz\r\n--MIMEBOUNDARY--\r\n
Developing the Provider
If you wish to work on the provider, you'll first need Go installed on your machine (version 1.8+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin
to your $PATH
.
To compile the provider, run make build
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
$ make bin
...
$ $GOPATH/bin/terraform-provider-cloudinit
...
In order to test the provider, you can simply run make test
.
$ make test
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create real resources, and often cost money to run.
$ make testacc