Skip to content

NikolaLohinski/terraform-provider-jinja

Repository files navigation

terraform-provider-jinja

A terraform provider that makes it possible to render Jinja templates within a terraform project.

The Jinja engine used under the hood is based on the gonja Golang library and aims to be as close as possible to python's Jinja.

The JSON schema validation engine is based on the jsonschema Golang library.

Example

provider "jinja" {
  strict_undefined = true
}

data "jinja_template" "render" {
  source {
    template  = file("${path.module}/template.j2")
    directory = path.module
  }
  context {
    type = "yaml"
    data = "${path.module}/src/context.yaml"
  }
}

output "rendered" {
  value = data.jinja_template.render.result
}

You can run a full example from the dedicated sub-folder.

Provider documentation

ℹ️ The documentation folder is generated using tfplugindocs and running make docs.

Development

Guidelines

Please read through the contribution guidelines before diving into any work.

Requirements

Tests

The unit tests can be run using:

make test

Local provider installation

The provider can be installed locally, using:

make install

See the Makefile for more details on what it means.

Running the example

The example located under examples/ can be ran with:

make example