terraform-provider-string-template

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 5 Imported by: 0

README

Terraform Provider String Template

A simple provider that exposes a singular provider function named template. This function consumes an HCL string template along with a values map to use in the templating process.

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
go install

Then commit the changes to go.mod and go.sum.

Using the provider

terraform {
  required_providers {
    vault = {
      source = "mbillow/string-template"
      version = "???"
    }
  }
}

variable "demo_template" {
  type = string
  description = "User provided HCL template string."
  // Since we are defining a default inline, we need to use %% and $$ to get the literals % and $.
  // Your templates don't need double characters if they are coming from outside your HCL.
  default = <<-EOT
  %%{ for ip in split(",", ip_addresses) ~}
  $${ ip }
  %%{ endfor ~}
  EOT
}

locals = {
  template_vars = {
    ip_addresses = "1.1.1.1,2.2.2.2,3.3.3.3"
  }
}

output "demo" {
  value = provider::string-template::template(
    var.demo_template,
    local.template_vars
  )
}

Output:

1.1.1.1
2.2.2.2
3.3.3.3

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine ( see Requirements above).

To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.

To generate or update documentation, run go generate.

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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