terraform-provider-ct

terraform-provider-ct allows defining a ct_config Container Linux Config resource to validate the content and render an Ignition document. Rendered Ignition may be used as input to other Terraform resources (e.g. instance user-data).

Requirements

Install

Add the terraform-provider-ct plugin binary for your system to the Terraform 3rd-party plugin directory ~/.terraform.d/plugins.

VERSION=v0.3.2
wget https://github.com/poseidon/terraform-provider-ct/releases/download/$VERSION/terraform-provider-ct-$VERSION-linux-amd64.tar.gz
tar xzf terraform-provider-ct-$VERSION-linux-amd64.tar.gz
mv terraform-provider-ct-$VERSION-linux-amd64/terraform-provider-ct ~/.terraform.d/plugins/terraform-provider-ct_$VERSION

Terraform plugin binary names are versioned to allow for migrations of managed infrastructure.

$ tree ~/.terraform.d/
/home/user/.terraform.d/
└── plugins
    ├── terraform-provider-ct_v0.3.0
    ├── terraform-provider-ct_v0.3.1
    └── terraform-provider-ct_v0.3.2

Usage

Configure the ct provider in a providers.tf file.

provider "ct" {
  version = "0.3.2"
}

Run terraform init to ensure plugin version requirements are met.

$ terraform init

Declare a ct_config resource in Terraform.

data "ct_config" "worker" {
  content      = "${file("worker.yaml")}"
  platform     = "ec2"
  pretty_print = false

  snippets = [
    "${file("units.yaml")}",
    "${file("storage.yaml")}",
  ]
}

resource "aws_instance" "worker" {
  user_data = "${data.ct_config.worker.rendered}"
}

Set the content to the contents of a Container Linux Config that should be validated and rendered as Ignition. Optionally, use the snippets field to append a list of Container Linux Config snippets. Use platform if platform-specific susbstitution is desired.

Ignition schema output

Each minor version of terraform-provider-ct is tightly coupled with a minor version of the Ignition schema. Ignition transparently handles old Ignition schema versions, so this isn't normally an issue.

Upgrading between versions for existing managed clusters may not be safe. Check your usage to determine whether a user_data change to an instance would re-provision a machine (important machines may be configured to ignore user_data changes).

terraform-provider-ct Ignition schema version
0.2.x 2.0
0.3.x 2.2

Development

Binary

To develop the provider plugin locally, build an executable with Go v1.11+.

make

Vendor

Add or update dependencies in go.mod and vendor.

make update
make vendor
Description
No description provided
Readme Apache-2.0 11 MiB
Languages
Go 92.7%
Makefile 7.3%