Documentation ¶
Overview ¶
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.
Index ¶
- func CollectFromEnvVars(to map[string]UnparsedVariableValue)
- func CollectFromFile(filename string, to map[string]UnparsedVariableValue) error
- func CollectFromString(raw string, to map[string]UnparsedVariableValue) error
- func LookupTFVarsFiles(dir string) []string
- func WriteAsEnvVars(w io.Writer, vars []Variable) error
- func WriteAsTFVars(w io.Writer, vars []Variable) error
- func WriteAsTerraformCode(w io.Writer, vars []Variable, org string, workspace string) error
- type UnparsedVariableValue
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
WriteAsEnvVars outputs the given vars in environment variables format, e.g.
export TF_VAR_region='ap-northeast-1'
func WriteAsTFVars ¶
WriteAsTFVars outputs the given vars in Terraform's variable definitions format, e.g.
region = "ap-northeast-1"
Types ¶
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 ¶
Variable represents a simplified version of Terraform's input variable, e.g.
variable "image_id" { type = string }
func Load ¶
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.