Version: v0.5.0 Latest Latest

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 15 Imported by: 0



Package tfvar contains the essential tools to extract input variables from Terraform configurations, retrieve variable definitions from sources, and parse those values back into the input variables.



This section is empty.


This section is empty.


func CollectFromEnvVars

func CollectFromEnvVars(to map[string]UnparsedVariableValue)

CollectFromEnvVars extracts the variable definitions from all environment variables that prefixed with TF_VAR_.

func CollectFromFile

func CollectFromFile(filename string, to map[string]UnparsedVariableValue) error

CollectFromFile extracts the variable definitions from the given file.

func CollectFromString

func CollectFromString(raw string, to map[string]UnparsedVariableValue) error

CollectFromString extracts the variable definition from the given string.

func LookupTFVarsFiles

func LookupTFVarsFiles(dir string) []string

LookupTFVarsFiles search for terraform.tfvars, terraform.tfvars.json, *.auto.tfvars, and *.auto.tfvars.json in dir. The value of dir is include in the returned value.

func WriteAsEnvVars

func WriteAsEnvVars(w io.Writer, vars []Variable) error

WriteAsEnvVars outputs the given vars in environment variables format, e.g.

export TF_VAR_region='ap-northeast-1'

func WriteAsTFEResource added in v0.5.0

func WriteAsTFEResource(w io.Writer, vars []Variable) error

func WriteAsTFVars

func WriteAsTFVars(w io.Writer, vars []Variable) error

WriteAsTFVars outputs the given vars in Terraform's variable definitions format, e.g.

region = "ap-northeast-1"

func WriteAsWorkspacePayload added in v0.5.0

func WriteAsWorkspacePayload(w io.Writer, vars []Variable) error


type UnparsedVariableValue

type UnparsedVariableValue interface {
	ParseVariableValue(configs.VariableParsingMode) (cty.Value, error)

UnparsedVariableValue describes the value of variable definitions defined in tfvars files, environment variables, and raw string.

type Variable

type Variable struct {
	Name        string
	Value       cty.Value
	Description string
	Sensitive   bool
	// contains filtered or unexported fields

Variable represents a simplified version of Terraform's input variable, e.g.

variable "image_id" {
  type = string

func Load

func Load(dir string) ([]Variable, error)

Load extracts all input variables declared in the Terraform configurations located in dir.

func ParseValues

func ParseValues(from map[string]UnparsedVariableValue, vars []Variable) ([]Variable, error)

ParseValues assigns defined variables into the matching declared variables.

Jump to

Keyboard shortcuts

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