config

package
v2.7.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultConfigName is the name of the default file name where to store terragrunt definitions
	DefaultConfigName = options.DefaultConfigName

	// TerragruntScriptFolder is the name of the scripts folder generated under the temporary terragrunt folder
	TerragruntScriptFolder = ".terragrunt-scripts"
)

Variables

View Source
var AfterInitState = func(hook Hook) bool { return hook.AfterInitState && !hook.BeforeImports }

AfterInitState is a filter function

View Source
var BeforeImports = func(hook Hook) bool { return hook.BeforeImports }

BeforeImports is a filter function

View Source
var BeforeInitState = func(hook Hook) bool { return !hook.AfterInitState && !hook.BeforeImports }

BeforeInitState is a filter function

View Source
var TerraformCommandWithInput = []string{
	"apply",
	"import",
	"init",
	"plan",
	"refresh",
}

TerraformCommandWithInput is the list of Terraform commands accepting --input

View Source
var TerraformCommandWithLockTimeout = []string{
	"apply",
	"destroy",
	"import",
	"init",
	"plan",
	"refresh",
	"taint",
	"untaint",
}

TerraformCommandWithLockTimeout is the list of Terraform commands accepting --lock-timeout

View Source
var TerraformCommandWithVarFile = []string{
	"apply",
	"console",
	"destroy",
	"import",
	"plan",
	"push",
	"refresh",
	"validate",
}

TerraformCommandWithVarFile is the list of Terraform commands accepting -var-file

View Source
var TitleID = color.New(color.FgHiYellow).SprintFunc()

TitleID add formating to the id of the elements

Functions

This section is empty.

Types

type ActualCommand

type ActualCommand struct {
	Command  string
	BehaveAs string
	Extra    *ExtraCommand
}

ActualCommand represents the command that should be executed

type ApprovalConfig

type ApprovalConfig struct {
	TerragruntExtensionBase `hcl:",remain"`

	Commands            []string `hcl:"commands"`
	ExpectStatements    []string `hcl:"expect_statements"`
	CompletedStatements []string `hcl:"completed_statements"`
}

ApprovalConfig represents an `expect` format configuration that instructs terragrunt to wait for input on an ExpectStatement and to exit the command on a CompletedStatement

func (ApprovalConfig) String

func (item ApprovalConfig) String() string

type ApprovalConfigList

type ApprovalConfigList []ApprovalConfig

ApprovalConfigList represents an array of ApprovalConfig

func (ApprovalConfigList) Enabled

func (list ApprovalConfigList) Enabled() ApprovalConfigList

Enabled returns only the enabled items on the list

func (ApprovalConfigList) Help

func (list ApprovalConfigList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

func (*ApprovalConfigList) Merge

func (list *ApprovalConfigList) Merge(imported ApprovalConfigList)

Merge elements from an imported list to the current list

func (ApprovalConfigList) ShouldBeApproved

func (list ApprovalConfigList) ShouldBeApproved(command string) (bool, *ApprovalConfig)

ShouldBeApproved looks for an approval config that corresponds to the given command. If if exists, it's returned with the value `true`.

type Condition

type Condition map[string]interface{}

Condition defines a single condition

func (Condition) String

func (c Condition) String() string

type ExportVariablesConfig

type ExportVariablesConfig struct {
	Path        string `hcl:"path"`
	Format      string `hcl:"format,optional"`
	SkipOnError bool   `hcl:"skip_on_error,optional"`
	// contains filtered or unexported fields
}

ExportVariablesConfig represents a path and format where variables known to Terragrunt should be exported

type ExtraCommand

type ExtraCommand struct {
	TerragruntExtensionBase `hcl:",remain"`

	Commands     []string          `hcl:"commands,optional"`
	Aliases      []string          `hcl:"aliases,optional"`
	Arguments    []string          `hcl:"arguments,optional"`
	ExpandArgs   *bool             `hcl:"expand_args,optional"`
	UseState     *bool             `hcl:"use_state,optional"`
	ActAs        string            `hcl:"act_as,optional"`
	VersionArg   string            `hcl:"version,optional"`
	ShellCommand bool              `hcl:"shell_command,optional"` // This indicates that the command is a shell command and output should not be redirected
	IgnoreError  bool              `hcl:"ignore_error,optional"`
	EnvVars      map[string]string `hcl:"env_vars,optional"`
}

ExtraCommand is a definition of user extra command that should be executed in place of terraform

type ExtraCommandList

type ExtraCommandList []ExtraCommand

ExtraCommandList represents an array of ExtraCommand

func (ExtraCommandList) ActualCommand

func (list ExtraCommandList) ActualCommand(cmd string) ActualCommand

ActualCommand returns

func (ExtraCommandList) Enabled

func (list ExtraCommandList) Enabled() ExtraCommandList

Enabled returns only the enabled items on the list

func (ExtraCommandList) GetVersions

func (list ExtraCommandList) GetVersions() string

GetVersions returns the the list of versions for extra commands that have a version available

func (ExtraCommandList) Help

func (list ExtraCommandList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

func (*ExtraCommandList) Merge

func (list *ExtraCommandList) Merge(imported ExtraCommandList)

Merge elements from an imported list to the current list

type GenericItem

type GenericItem generic.Type

GenericItem is a generic implementation

type GenericItemList

type GenericItemList []GenericItem

GenericItemList represents an array of GenericItem

func (GenericItemList) Enabled

func (list GenericItemList) Enabled() GenericItemList

Enabled returns only the enabled items on the list

func (GenericItemList) Help

func (list GenericItemList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

type Hook

type Hook struct {
	TerragruntExtensionBase `hcl:",remain"`

	Type              HookType
	Command           string            `hcl:"command"`
	Arguments         []string          `hcl:"arguments,optional"`
	ExpandArgs        bool              `hcl:"expand_args,optional"`
	OnCommands        []string          `hcl:"on_commands,optional"`
	IgnoreError       bool              `hcl:"ignore_error,optional"`
	RunOnErrors       bool              `hcl:"run_on_errors,optional"`
	BeforeImports     bool              `hcl:"before_imports,optional"`
	AfterInitState    bool              `hcl:"after_init_state,optional"`
	Order             int               `hcl:"order,optional"`
	ShellCommand      bool              `hcl:"shell_command,optional"` // This indicates that the command is a shell command and output should not be redirected
	EnvVars           map[string]string `hcl:"env_vars,optional"`
	PersistentEnvVars map[string]string `hcl:"persistent_env_vars,optional"`
}

Hook is a definition of user command that should be executed as part of the terragrunt process

type HookFilter

type HookFilter func(Hook) bool

HookFilter is used to filter the hook on supplied criteria

type HookList

type HookList []Hook

HookList represents an array of Hook

func (HookList) Enabled

func (list HookList) Enabled() HookList

Enabled returns only the enabled items on the list

func (HookList) Filter

func (list HookList) Filter(filter HookFilter) HookList

Filter returns a list of hook that match the supplied filter

func (HookList) Help

func (list HookList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

func (*HookList) MergeAppend

func (list *HookList) MergeAppend(imported HookList)

MergeAppend appends elements from an imported list to the current list

func (*HookList) MergePrepend

func (list *HookList) MergePrepend(imported HookList)

MergePrepend prepends elements from an imported list to the current list

func (HookList) Run

func (list HookList) Run(status error, args ...interface{}) (result []interface{}, err error)

Run execute the content of the list

type HookType added in v2.7.2

type HookType int
const (
	UnsetHookType HookType = iota
	PreHookType
	PostHookType
)

func (HookType) String added in v2.7.2

func (hookType HookType) String() string

type ImportFiles

type ImportFiles struct {
	TerragruntExtensionBase `hcl:",remain"`

	Source            string          `hcl:"source,optional"`
	Files             []string        `hcl:"files"`
	CopyAndRename     []copyAndRename `hcl:"copy_and_remove,optional"`
	Required          *bool           `hcl:"required,optional"`
	ImportIntoModules bool            `hcl:"import_into_modules,optional"`
	FileMode          *int            `hcl:"file_mode,optional"`
	Target            string          `hcl:"target,optional"`
	Prefix            *string         `hcl:"prefix,optional"`
	SourceFileRegex   string          `hcl:"source_file_regex,optional"`
}

ImportFiles is a configuration of files that must be imported from another directory to the terraform directory prior executing terraform commands

type ImportFilesList

type ImportFilesList []ImportFiles

ImportFilesList represents an array of ImportFiles

func (ImportFilesList) Enabled

func (list ImportFilesList) Enabled() ImportFilesList

Enabled returns only the enabled items on the list

func (ImportFilesList) Help

func (list ImportFilesList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

func (*ImportFilesList) Merge

func (list *ImportFilesList) Merge(imported ImportFilesList)

Merge elements from an imported list to the current list

func (ImportFilesList) Run

func (list ImportFilesList) Run(status error, args ...string) (err error)

Run execute the content of the list

type ImportVariables

type ImportVariables struct {
	TerragruntExtensionBase `hcl:",remain"`

	Vars             []string          `hcl:"vars,optional"`
	RequiredVarFiles []string          `hcl:"required_var_files,optional"`
	OptionalVarFiles []string          `hcl:"optional_var_files,optional"`
	NoTemplating     bool              `hcl:"no_templating_in_files,optional"`
	Sources          []string          `hcl:"sources,optional"`
	NestedObjects    []string          `hcl:"nested_under,optional"`
	EnvVars          map[string]string `hcl:"env_vars,optional"`
	OnCommands       []string          `hcl:"on_commands,optional"`
	SourceFileRegex  string            `hcl:"source_file_regex,optional"`
}

ImportVariables is a configuration that allows defintion of variables that will be added to the current execution. Variables could be defined either by loading files (required or optional) or defining vairables directly. It is also possible to define global environment variables.

type ImportVariablesList

type ImportVariablesList []ImportVariables

ImportVariablesList represents an array of ImportVariables

func (ImportVariablesList) Enabled

Enabled returns only the enabled items on the list

func (ImportVariablesList) Help

func (list ImportVariablesList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

func (ImportVariablesList) Import

func (list ImportVariablesList) Import() (err error)

Import actually process the variables importers to load and define all variables in the current context

func (*ImportVariablesList) Merge

func (list *ImportVariablesList) Merge(imported ImportVariablesList)

Merge elements from an imported list to the current list

type IncludeConfig

type IncludeConfig struct {
	Source string `hcl:"source,optional"`
	Path   string `hcl:"path,optional"`
	// contains filtered or unexported fields
}

IncludeConfig represents the configuration settings for a parent Terragrunt configuration file that you can "include" in a child Terragrunt configuration file

func (IncludeConfig) String

func (include IncludeConfig) String() string

type ModuleDependencies

type ModuleDependencies struct {
	Paths []string `hcl:"paths"`
}

ModuleDependencies represents the paths to other Terraform modules that must be applied before the current module can be applied

func (*ModuleDependencies) String

func (deps *ModuleDependencies) String() string

type RunConditions

type RunConditions struct {
	Allows []Condition
	Denies []Condition
}

RunConditions defines the rules that are evaluated in order to determine

func (*RunConditions) Merge

func (c *RunConditions) Merge(imported RunConditions)

Merge combines RunConditions from another source into the current one

func (RunConditions) ShouldRun

func (c RunConditions) ShouldRun() bool

ShouldRun returns whether or not the current project should be run based on its run conditions and the variables in its options.

func (RunConditions) String

func (c RunConditions) String() (result string)

type TerraformConfig

type TerraformConfig struct {
	LegacyExtraArgs TerraformExtraArgumentsList `hcl:"extra_arguments,block"` // Kept here only for retro compatibility
	Source          string                      `hcl:"source,optional"`
}

TerraformConfig specifies where to find the Terraform configuration files

func (TerraformConfig) String

func (conf TerraformConfig) String() string

type TerraformExtraArguments

type TerraformExtraArguments struct {
	TerragruntExtensionBase `hcl:",remain"`

	Source           string            `hcl:"source,optional"`
	Arguments        []string          `hcl:"arguments,optional"`
	RequiredVarFiles []string          `hcl:"required_var_files,optional"`
	OptionalVarFiles []string          `hcl:"optional_var_files,optional"`
	Commands         []string          `hcl:"commands,optional"`
	EnvVars          map[string]string `hcl:"env_vars,optional"`
}

TerraformExtraArguments sets a list of arguments to pass to Terraform if command fits any in the `Commands` list

type TerraformExtraArgumentsList

type TerraformExtraArgumentsList []TerraformExtraArguments

TerraformExtraArgumentsList represents an array of TerraformExtraArguments

func (TerraformExtraArgumentsList) Enabled

Enabled returns only the enabled items on the list

func (TerraformExtraArgumentsList) Filter

func (list TerraformExtraArgumentsList) Filter(source string) (result []string, err error)

Filter applies extra_arguments to the current configuration

func (TerraformExtraArgumentsList) Help

func (list TerraformExtraArgumentsList) Help(listOnly bool, lookups ...string) (result string)

Help returns the information relative to the elements within the list

func (*TerraformExtraArgumentsList) Merge

Merge elements from an imported list to the current list

type TerragruntConfig

type TerragruntConfig struct {
	ApprovalConfig          ApprovalConfigList          `hcl:"approval_config,block" export:"true"`
	AssumeRole              []string                    `export:"true"`
	AssumeRoleDurationHours *int                        `hcl:"assume_role_duration_hours,attr" export:"true"`
	Dependencies            *ModuleDependencies         `hcl:"dependencies,block" export:"true"`
	Description             string                      `hcl:"description,optional" export:"true"`
	ExportVariablesConfigs  []ExportVariablesConfig     `hcl:"export_variables,block" export:"true"`
	ExportConfigConfigs     []ExportVariablesConfig     `hcl:"export_config,block" export:"true"`
	ExtraArgs               TerraformExtraArgumentsList `hcl:"extra_arguments,block" export:"true"`
	ExtraCommands           ExtraCommandList            `hcl:"extra_command,block" export:"true"`
	ImportFiles             ImportFilesList             `hcl:"import_files,block" export:"true"`
	ImportVariables         ImportVariablesList         `hcl:"import_variables,block" export:"true"`
	Inputs                  map[string]interface{}
	PreHooks                HookList      `hcl:"pre_hook,block" export:"true"`
	PostHooks               HookList      `hcl:"post_hook,block" export:"true"`
	RemoteState             *remote.State `hcl:"remote_state,block" export:"true"`
	RunConditions           RunConditions
	Terraform               *TerraformConfig `hcl:"terraform,block" export:"true"`
	UniquenessCriteria      *string          `hcl:"uniqueness_criteria,attr" export:"true"`

	AssumeRoleHclDefinition    cty.Value                    `hcl:"assume_role,optional"`
	InputsHclDefinition        cty.Value                    `hcl:"inputs,optional"`
	RunConditionsHclDefinition []runConditionsHclDefinition `hcl:"run_conditions,block"`
	// contains filtered or unexported fields
}

TerragruntConfig represents a parsed and expanded configuration

func ParseConfigFile

func ParseConfigFile(terragruntOptions *options.TerragruntOptions, include IncludeConfig) (configString string, config *TerragruntConfig, err error)

ParseConfigFile parses the Terragrunt config file at the given path. If the include parameter is not nil, then treat this as a config included in some other config file when resolving relative paths.

func ReadTerragruntConfig

func ReadTerragruntConfig(terragruntOptions *options.TerragruntOptions) (*TerragruntConfig, error)

ReadTerragruntConfig reads the Terragrunt config file from its default location

func (TerragruntConfig) AsDictionary added in v2.6.0

func (conf TerragruntConfig) AsDictionary() (result collections.IDictionary, err error)

AsDictionary exports tagged (export: true) properties of the configuration as a dictionary

func (*TerragruntConfig) ExportVariables

func (conf *TerragruntConfig) ExportVariables(existingTerraformVariables map[string]*configs.Variable, folders ...string) (err error)

ExportVariables saves variables to paths defined in the export_variables blocks

func (TerragruntConfig) ExtraArguments

func (conf TerragruntConfig) ExtraArguments(source string) ([]string, error)

ExtraArguments processes the extra_arguments defined in the terraform section of the config file

func (TerragruntConfig) String

func (conf TerragruntConfig) String() string

type TerragruntConfigFile

type TerragruntConfigFile struct {
	Path string
	// remain will send everything that isn't match into the labelled struct
	// In that case, most of the config goes down to TerragruntConfig
	// https://godoc.org/github.com/hashicorp/hcl/v2/gohcl
	TerragruntConfig `hcl:",remain"`
	Include          *IncludeConfig `hcl:"include,block"`
}

TerragruntConfigFile represents the configuration supported in a Terragrunt configuration file (i.e. terragrunt.hcl)

func (*TerragruntConfigFile) GetSourceFolder

func (tcf *TerragruntConfigFile) GetSourceFolder(name string, source string, failIfNotFound bool, fileRegex string) (string, error)

GetSourceFolder resolves remote source and returns the local temporary folder If the source is local, it is directly returned

func (TerragruntConfigFile) String

func (tcf TerragruntConfigFile) String() string

type TerragruntExtensionBase

type TerragruntExtensionBase struct {
	Name        string   `hcl:"name,label"`
	DisplayName string   `hcl:"display_name,optional"`
	Description string   `hcl:"description,optional"`
	OS          []string `hcl:"os,optional"`
	Disabled    bool     `hcl:"disabled,optional"`
	// contains filtered or unexported fields
}

TerragruntExtensionBase is the base object to define object used to extend the behavior of terragrunt

func (TerragruntExtensionBase) String

func (base TerragruntExtensionBase) String() string

type TerragruntExtensioner

type TerragruntExtensioner interface {
	// contains filtered or unexported methods
}

TerragruntExtensioner defines the interface that must be implemented by Terragrunt Extension objects

func IApprovalConfig

func IApprovalConfig(item interface{}) TerragruntExtensioner

IApprovalConfig returns TerragruntExtensioner from the supplied type

func IExtraCommand

func IExtraCommand(item interface{}) TerragruntExtensioner

IExtraCommand returns TerragruntExtensioner from the supplied type

func IGenericItem

func IGenericItem(item interface{}) TerragruntExtensioner

IGenericItem returns TerragruntExtensioner from the supplied type

func IHook

func IHook(item interface{}) TerragruntExtensioner

IHook returns TerragruntExtensioner from the supplied type

func IImportFiles

func IImportFiles(item interface{}) TerragruntExtensioner

IImportFiles returns TerragruntExtensioner from the supplied type

func IImportVariables

func IImportVariables(item interface{}) TerragruntExtensioner

IImportVariables returns TerragruntExtensioner from the supplied type

func ITerraformExtraArguments

func ITerraformExtraArguments(item interface{}) TerragruntExtensioner

ITerraformExtraArguments returns TerragruntExtensioner from the supplied type

Jump to

Keyboard shortcuts

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