tfvar

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 15 Imported by: 0

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

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

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

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

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