config

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTerragruntConfigPath is the name of the default file name where to store terragrunt definitions
	DefaultTerragruntConfigPath = "terraform.tfvars"

	// OldTerragruntConfigPath is the name of the legacy file name used to store terragrunt definitions
	OldTerragruntConfigPath = ".terragrunt"

	// 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

func DefaultConfigPath added in v0.10.0

func DefaultConfigPath(workingDir string) string

DefaultConfigPath returns the default path to use for the Terragrunt configuration file. The reason this is a method rather than a constant is that older versions of Terragrunt stored configuration in a different file. This method returns the path to the old configuration format if such a file exists and the new format otherwise.

func FindConfigFilesInPath added in v0.10.0

func FindConfigFilesInPath(terragruntOptions *options.TerragruntOptions) ([]string, error)

FindConfigFilesInPath returns a list of all Terragrunt config files in the given path or any subfolder of the path. A file is a Terragrunt config file if it has a name as returned by the DefaultConfigPath method and contains Terragrunt config contents as returned by the IsTerragruntConfigFile method.

func IsTerragruntConfigFile added in v0.10.0

func IsTerragruntConfigFile(path string) (bool, error)

IsTerragruntConfigFile returns true if the given path corresponds to file that could be a Terragrunt config file. A file could be a Terragrunt config file if:

  1. The file exists
  2. It is a .terragrunt file, which is the old Terragrunt-specific file format
  3. The file contains HCL contents with a terragrunt = { ... } block

func ResolveTerragruntConfigString added in v0.4.0

func ResolveTerragruntConfigString(terragruntConfigString string, include IncludeConfig, terragruntOptions *options.TerragruntOptions) (string, error)

ResolveTerragruntConfigString Given a string value from a Terragrunt configuration, parse the string, resolve any calls to helper functions using the syntax ${...}, and return the final value.

func SubstituteVars added in v1.0.0

func SubstituteVars(str string, terragruntOptions *options.TerragruntOptions) string

SubstituteVars substitutes any variables in the string if there is a value associated with the variable

Types

type ActualCommand added in v1.0.0

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

ActualCommand represents the command that should be executed

type ApprovalConfig added in v1.0.0

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

	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 added in v1.0.0

func (item ApprovalConfig) String() string

type ApprovalConfigList added in v1.0.0

type ApprovalConfigList []ApprovalConfig

ApprovalConfigList represents an array of ApprovalConfig

func (ApprovalConfigList) Enabled added in v1.0.0

func (list ApprovalConfigList) Enabled() ApprovalConfigList

Enabled returns only the enabled items on the list

func (ApprovalConfigList) Help added in v1.0.0

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

Help returns the information relative to the elements within the list

func (*ApprovalConfigList) Merge added in v1.0.0

func (list *ApprovalConfigList) Merge(imported ApprovalConfigList)

Merge elements from an imported list to the current list

func (ApprovalConfigList) ShouldBeApproved added in v1.0.0

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 added in v1.2.4

type Condition map[string]interface{}

Condition defines a single condition

func (Condition) String added in v1.2.4

func (c Condition) String() string

type CouldNotResolveTerragruntConfigInFile added in v0.10.0

type CouldNotResolveTerragruntConfigInFile string

CouldNotResolveTerragruntConfigInFile is the error returned when the configuration file could not be resolved

func (CouldNotResolveTerragruntConfigInFile) Error added in v0.10.0

type ExtraCommand added in v1.0.0

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

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

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

type ExtraCommandList added in v1.0.0

type ExtraCommandList []ExtraCommand

ExtraCommandList represents an array of ExtraCommand

func (ExtraCommandList) ActualCommand added in v1.0.0

func (list ExtraCommandList) ActualCommand(cmd string) ActualCommand

ActualCommand returns

func (ExtraCommandList) Enabled added in v1.0.0

func (list ExtraCommandList) Enabled() ExtraCommandList

Enabled returns only the enabled items on the list

func (ExtraCommandList) GetVersions added in v1.0.0

func (list ExtraCommandList) GetVersions() string

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

func (ExtraCommandList) Help added in v1.0.0

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

Help returns the information relative to the elements within the list

func (*ExtraCommandList) Merge added in v1.0.0

func (list *ExtraCommandList) Merge(imported ExtraCommandList)

Merge elements from an imported list to the current list

type GenericItem added in v1.0.0

type GenericItem generic.Type

GenericItem is a generic implementation

type GenericItemList added in v1.0.0

type GenericItemList []GenericItem

GenericItemList represents an array of GenericItem

func (GenericItemList) Enabled added in v1.0.0

func (list GenericItemList) Enabled() GenericItemList

Enabled returns only the enabled items on the list

func (GenericItemList) Help added in v1.0.0

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

Help returns the information relative to the elements within the list

type Hook added in v1.0.0

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

	Command        string   `hcl:"command"`
	Arguments      []string `hcl:"arguments"`
	ExpandArgs     bool     `hcl:"expand_args"`
	OnCommands     []string `hcl:"on_commands"`
	IgnoreError    bool     `hcl:"ignore_error"`
	BeforeImports  bool     `hcl:"before_imports"`
	AfterInitState bool     `hcl:"after_init_state"`
	Order          int      `hcl:"order"`
	ShellCommand   bool     `hcl:"shell_command"` // This indicates that the command is a shell command and output should not be redirected
}

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

type HookFilter added in v1.0.0

type HookFilter func(Hook) bool

HookFilter is used to filter the hook on supplied criteria

type HookList added in v1.0.0

type HookList []Hook

HookList represents an array of Hook

func (HookList) Enabled added in v1.0.0

func (list HookList) Enabled() HookList

Enabled returns only the enabled items on the list

func (HookList) Filter added in v1.0.0

func (list HookList) Filter(filter HookFilter) HookList

Filter returns a list of hook that match the supplied filter

func (HookList) Help added in v1.0.0

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

Help returns the information relative to the elements within the list

func (*HookList) MergeAppend added in v1.0.0

func (list *HookList) MergeAppend(imported HookList)

MergeAppend appends elements from an imported list to the current list

func (*HookList) MergePrepend added in v1.0.0

func (list *HookList) MergePrepend(imported HookList)

MergePrepend prepends elements from an imported list to the current list

func (HookList) Run added in v1.0.0

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

Run execute the content of the list

type ImportFiles added in v1.0.0

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

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

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

type ImportFilesList added in v1.0.0

type ImportFilesList []ImportFiles

ImportFilesList represents an array of ImportFiles

func (ImportFilesList) Enabled added in v1.0.0

func (list ImportFilesList) Enabled() ImportFilesList

Enabled returns only the enabled items on the list

func (ImportFilesList) Help added in v1.0.0

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

Help returns the information relative to the elements within the list

func (*ImportFilesList) Merge added in v1.0.0

func (list *ImportFilesList) Merge(imported ImportFilesList)

Merge elements from an imported list to the current list

func (ImportFilesList) Run added in v1.0.0

func (list ImportFilesList) Run(status error, args ...interface{}) (err error)

Run execute the content of the list

func (ImportFilesList) RunOnModules added in v1.0.0

func (list ImportFilesList) RunOnModules(terragruntOptions *options.TerragruntOptions) (err error)

RunOnModules executes list configuration on module folders

type ImportVariables added in v1.3.0

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

	Source           string   `hcl:"source"`
	Vars             []string `hcl:"vars"`
	RequiredVarFiles []string `hcl:"required_var_files"`
	OptionalVarFiles []string `hcl:"optional_var_files"`

	NestedUnder string `hcl:"nested_under"`

	TFVariablesFile string `hcl:"output_variables_file"`
	FlattenLevels   *int   `hcl:"flatten_levels"`
}

type ImportVariablesList added in v1.3.0

type ImportVariablesList []ImportVariables

ImportVariablesList represents an array of ImportVariables

func (ImportVariablesList) CreatesVariableFile added in v1.3.0

func (list ImportVariablesList) CreatesVariableFile() bool

func (ImportVariablesList) Enabled added in v1.3.0

Enabled returns only the enabled items on the list

func (ImportVariablesList) Help added in v1.3.0

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

Help returns the information relative to the elements within the list

func (ImportVariablesList) Import added in v1.3.0

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

func (*ImportVariablesList) Merge added in v1.3.0

func (list *ImportVariablesList) Merge(imported ImportVariablesList)

Merge elements from an imported list to the current list

type IncludeConfig added in v0.4.0

type IncludeConfig struct {
	Source string `hcl:"source"`
	Path   string `hcl:"path"`
	// 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 added in v1.0.0

func (include IncludeConfig) String() string

type IncludedConfigMissingPath added in v0.4.0

type IncludedConfigMissingPath string

IncludedConfigMissingPath is the error returned when there is no path defined in the include directive

func (IncludedConfigMissingPath) Error added in v0.4.0

func (err IncludedConfigMissingPath) Error() string

type LockConfig added in v0.1.0

type LockConfig map[interface{}]interface{}

LockConfig is older versions of Terraform did not support locking, so Terragrunt offered locking as a feature. As of version 0.9.0, Terraform supports locking natively, so this feature was removed from Terragrunt. However, we keep around the LockConfig so we can log a warning for Terragrunt users who are still trying to use it.

type ModuleDependencies added in v0.6.0

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 added in v0.9.4

func (deps *ModuleDependencies) String() string

type RunConditions added in v1.0.0

type RunConditions struct {
	Allows []Condition `hcl:"run_if"`
	Denies []Condition `hcl:"ignore_if"`
}

RunConditions defines the rules that are evaluated in order to determine

func (*RunConditions) Merge added in v1.2.4

func (c *RunConditions) Merge(imported RunConditions)

Merge combines RunConditions from another source into the current one

func (RunConditions) ShouldRun added in v1.0.0

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 added in v1.2.4

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

type TerraformConfig added in v0.9.4

type TerraformConfig struct {
	ExtraArgs TerraformExtraArgumentsList `hcl:"extra_arguments"`
	Source    string                      `hcl:"source"`
}

TerraformConfig specifies where to find the Terraform configuration files

func (TerraformConfig) String added in v0.9.4

func (conf TerraformConfig) String() string

type TerraformExtraArguments added in v0.10.2

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

	Source           string   `hcl:"source"`
	Arguments        []string `hcl:"arguments"`
	RequiredVarFiles []string `hcl:"required_var_files"`
	OptionalVarFiles []string `hcl:"optional_var_files"`
	Commands         []string `hcl:"commands"`
}

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

type TerraformExtraArgumentsList added in v1.0.0

type TerraformExtraArgumentsList []TerraformExtraArguments

TerraformExtraArgumentsList represents an array of TerraformExtraArguments

func (TerraformExtraArgumentsList) Enabled added in v1.0.0

Enabled returns only the enabled items on the list

func (TerraformExtraArgumentsList) Filter added in v1.0.0

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

Filter applies extra_arguments to the current configuration

func (TerraformExtraArgumentsList) Help added in v1.0.0

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

Help returns the information relative to the elements within the list

func (*TerraformExtraArgumentsList) Merge added in v1.0.0

Merge elements from an imported list to the current list

type TerragruntConfig

type TerragruntConfig struct {
	Description    string              `hcl:"description"`
	RunConditions  RunConditions       `hcl:"run_conditions"`
	Terraform      *TerraformConfig    `hcl:"terraform"`
	RemoteState    *remote.RemoteState `hcl:"remote_state"`
	Dependencies   *ModuleDependencies `hcl:"dependencies"`
	Uniqueness     *string             `hcl:"uniqueness_criteria"`
	AssumeRole     interface{}         `hcl:"assume_role"`
	PreHooks       HookList            `hcl:"pre_hook"`
	PostHooks      HookList            `hcl:"post_hook"`
	ExtraCommands  ExtraCommandList    `hcl:"extra_command"`
	ImportFiles    ImportFilesList     `hcl:"import_files"`
	ApprovalConfig ApprovalConfigList  `hcl:"approval_config"`

	ImportVariables ImportVariablesList `hcl:"import_variables"`
	// contains filtered or unexported fields
}

TerragruntConfig represents a parsed and expanded configuration

func ParseConfigFile added in v0.6.0

func ParseConfigFile(terragruntOptions *options.TerragruntOptions, include IncludeConfig) (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) ExtraArguments added in v1.0.0

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 added in v0.9.4

func (conf TerragruntConfig) String() string

func (*TerragruntConfig) SubstituteAllVariables added in v1.0.0

func (conf *TerragruntConfig) SubstituteAllVariables(terragruntOptions *options.TerragruntOptions, substituteFinal bool)

SubstituteAllVariables replace all remaining variables by the value

type TerragruntConfigFile added in v1.0.0

type TerragruntConfigFile struct {
	TerragruntConfig `hcl:",squash"`
	Include          *IncludeConfig
	Lock             *LockConfig
	Path             string
}

TerragruntConfigFile represents the configuration supported in a Terragrunt configuration file (i.e. terraform.tfvars or .terragrunt)

func (*TerragruntConfigFile) GetSourceFolder added in v1.3.0

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

func (TerragruntConfigFile) String added in v1.0.0

func (tcf TerragruntConfigFile) String() string

type TerragruntExtensionBase added in v1.0.0

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

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

func (TerragruntExtensionBase) String added in v1.0.0

func (base TerragruntExtensionBase) String() string

type TerragruntExtensioner added in v1.0.0

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

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

func IApprovalConfig added in v1.0.0

func IApprovalConfig(item interface{}) TerragruntExtensioner

IApprovalConfig returns TerragruntExtensioner from the supplied type

func IExtraCommand added in v1.0.0

func IExtraCommand(item interface{}) TerragruntExtensioner

IExtraCommand returns TerragruntExtensioner from the supplied type

func IGenericItem added in v1.0.0

func IGenericItem(item interface{}) TerragruntExtensioner

IGenericItem returns TerragruntExtensioner from the supplied type

func IHook added in v1.0.0

func IHook(item interface{}) TerragruntExtensioner

IHook returns TerragruntExtensioner from the supplied type

func IImportFiles added in v1.0.0

func IImportFiles(item interface{}) TerragruntExtensioner

IImportFiles returns TerragruntExtensioner from the supplied type

func IImportVariables added in v1.3.0

func IImportVariables(item interface{}) TerragruntExtensioner

IImportVariables returns TerragruntExtensioner from the supplied type

func ITerraformExtraArguments added in v1.0.0

func ITerraformExtraArguments(item interface{}) TerragruntExtensioner

ITerraformExtraArguments returns TerragruntExtensioner from the supplied type

type UnknownHelperFunction added in v0.4.0

type UnknownHelperFunction string

UnknownHelperFunction indicates an unknown invoked command

func (UnknownHelperFunction) Error added in v0.4.0

func (err UnknownHelperFunction) Error() string

Jump to

Keyboard shortcuts

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