Skip to content

Terraform provider to help with templating in terraform definitions.

License

Notifications You must be signed in to change notification settings

nrcxcia/terraform-provider-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-provider-utils

Build Status

A Terraform plugin to allow you to do custom templating (using the Go text/template library in Terraform.

We add a few simple functions to the defaults:

  • add $variable count - Adds the count to the variable when executed
  • split .argument "X" - Takes the argument and splits it by the second parameter

Example:

resource "utils_template" "zk_discovery_yaml" {
    template = <<EOT
---
zookeeper_servers:
{{range $index, $ip := split .ips ","}}  {{add $index 1}}: {{$ip}}
{{end}}
EOT
    vars {
        ips = "${join(",", aws_instance.zk.*.private_ip)}"
    }
}

and then elsewhere:

"${utils_template.zk_discovery_yaml.out}"

Resources

utils_template

Inputs:

  • template - The template text.
  • vars {} - Variables to pass to the template itself

Outputs:

  • out - The rendered template output

Further uses

Combining this provider with terraform-provider-gitfile allows terraform to commit the file you've templated to git - which can be useful for generating YAML or INI type config files for consumption by other systems (for example puppet).

License

Apache2 - See the included LICENSE file for more details.

About

Terraform provider to help with templating in terraform definitions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published