terraform-provider-cue

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 2 Imported by: 0

README

terraform-provider-cue

GoDoc Workflow Downloads Sponsors Mastodon

terraform-provider-cue allows Terraform to evaluate CUE configs and render JSON for use in Terraform.

Author's Note CUE has potential to be a better Jsonnet (if it gets a proper module manager). But like Jsonnet, its usage should be limited to preparing JSON-only configs where there are no viable alternatives (e.g. Grafana dashboards). Prefer native Terraform where possible, its ecosystem and design is simpler, more powerful, more mature, and ubiquitous.

Usage

Configure the cue provider (e.g. providers.tf).

provider "cue" {}

terraform {
  required_providers {
    ct = {
      source  = "poseidon/cue"
      version = "0.2.0"
    }
  }
}

Run terraform init to ensure version requirements are met.

$ terraform init -upgrade

Define a cue_config data source to validate CUE content.

data "cue_config" "example" {
  pretty_print = true
  content = <<EOF
a: 1
b: 2
sum: a + b
_hidden: 3
l: [a, b]

map: [string]:int
map: {a: 1 * 5}
map: {"b": b * 5}
EOF
}

Alternately, provide paths to CUE files (supports imports).

data "cue_config" "example" {
  paths = [
    "core.cue",
    "box.cue",
  ]
  pretty_print = false
}

Customize the root directory CUE uses during loading (defaults to current directory).

data "cue_config" "example" {
  paths = [
    "foo.cue",
  ]
  dir = "internal/testmod"
  pretty_print = false
}

Render the CUE config as JSON for use in Terraform expressions.

output "out" {
  description = "Show Cue rendered as JSON"
  value       = data.cue_config.example.rendered
}

The rendered content example looks like:

{
  "a": 1,
  "b": 2,
  "sum": 3,
  "l": [
    1,
    2
  ],
  "map": {
    "a": 5,
    "b": 10
  }
}

Requirements

Development

Binary

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

make

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL