Primitive Modules
This document describes how to use the Weave TF-controller with a primitive module. It requires TF-controller v0.13+ to run the example.
What is a primitive module?
It's a Terraform module that contains only a single resource.
- A Terraform primitive module must contains the "values" variable.
- The "values" variable must be an object with fields of optional types.
- The module must be placed under a directory, which is named after the resource.
- The directory can optionally contain other files, for example the .terraform.lock.hcl.
- We call a set of primitive modules bundled into an OCI image, a package.
Hello World Primitive Module
Here is an example of how a primitive module can be defined in YAML.
Assume that we have a ready-to-use OCI image with a primitive module for the imaginary resource aws_hello_world
,
and the image is tagged as ghcr.io/tf-controller/hello-primitive-modules/v4.32.0:v1
.
We'll use the following Terraform object definition to provision the resource.
We need to create a Terraform object with the
spec.sourceRef.kind
field set toOCIRepository
and thespec.sourceRef.name
field set to the name of the OCIRepository object.We need to set the
spec.path
field to the name of the resource, in this caseaws_hello_world
.We need to set the
spec.values
field to the values of the resource. This is a YAML object that will be converted to an HCL variable, and passed to the Terraform module.We need to set the
spec.approvePlan
field toauto
to automatically approve the plan.