Documentation ¶
Index ¶
- Constants
- Variables
- func ClearOutputCache()
- func CreateTerragruntEvalContext(filename string, terragruntOptions *options.TerragruntOptions, ...) *hcl.EvalContext
- func DefaultConfigPath(workingDir string) string
- func DefaultJsonConfigPath(workingDir string) string
- func FindConfigFilesInPath(rootPath string, terragruntOptions *options.TerragruntOptions) ([]string, error)
- func GetDefaultConfigPath(workingDir string) string
- type CouldNotEvaluateAllLocalsError
- type CouldNotResolveTerragruntConfigInFile
- type CtyJsonOutput
- type Dependency
- type DependencyConfigNotFound
- type DependencyCycle
- type EmptyStringNotAllowed
- type EnvVar
- type ErrorParsingTerragruntConfig
- type EvalContextExtensions
- type Hook
- type IncludeConfig
- type IncludedConfigMissingPath
- type InvalidArgError
- type InvalidBackendConfigType
- type InvalidGetEnvParams
- type InvalidParameterType
- type InvalidPartialBlockName
- type Local
- type MaxIterError
- type ModuleDependencies
- type PanicWhileParsingConfig
- type ParentFileNotFound
- type PartialDecodeSectionType
- type TerraformConfig
- type TerraformExtraArguments
- type TerragruntConfig
- func ParseConfigFile(filename string, terragruntOptions *options.TerragruntOptions, ...) (*TerragruntConfig, error)
- func ParseConfigString(configString string, terragruntOptions *options.TerragruntOptions, ...) (*TerragruntConfig, error)
- func PartialParseConfigFile(filename string, terragruntOptions *options.TerragruntOptions, ...) (*TerragruntConfig, error)
- func PartialParseConfigString(configString string, terragruntOptions *options.TerragruntOptions, ...) (*TerragruntConfig, error)
- func ReadTerragruntConfig(terragruntOptions *options.TerragruntOptions) (*TerragruntConfig, error)
- type TerragruntOutputEncodingError
- type TerragruntOutputListEncodingError
- type TerragruntOutputParsingError
- type TerragruntOutputTargetNoOutputs
- type TooManyLevelsOfInheritance
- type WrongNumberOfParams
Constants ¶
const DefaultTerragruntConfigPath = "terragrunt.hcl"
const DefaultTerragruntJsonConfigPath = "terragrunt.hcl.json"
const MaxIter = 1000
MaxIter is the maximum number of depth we support in recursively evaluating locals.
Variables ¶
var TERRAFORM_COMMANDS_NEED_INPUT = []string{
"apply",
"import",
"init",
"plan",
"refresh",
}
List of terraform commands that accept -input=
var TERRAFORM_COMMANDS_NEED_LOCKING = []string{
"apply",
"destroy",
"import",
"init",
"plan",
"refresh",
"taint",
"untaint",
}
List of terraform commands that accept -lock-timeout
var TERRAFORM_COMMANDS_NEED_PARALLELISM = []string{
"apply",
"plan",
"destroy",
}
List of terraform commands that accept -parallelism=
var TERRAFORM_COMMANDS_NEED_VARS = []string{
"apply",
"console",
"destroy",
"import",
"plan",
"push",
"refresh",
}
List of terraform commands that accept -var or -var-file
Functions ¶
func ClearOutputCache ¶ added in v0.21.2
func ClearOutputCache()
ClearOutputCache clears the output cache. Useful during testing.
func CreateTerragruntEvalContext ¶ added in v0.19.0
func CreateTerragruntEvalContext( filename string, terragruntOptions *options.TerragruntOptions, extensions EvalContextExtensions, ) *hcl.EvalContext
Create an EvalContext for the HCL2 parser. We can define functions and variables in this context that the HCL2 parser will make available to the Terragrunt configuration during parsing.
func DefaultConfigPath ¶ added in v0.10.0
Return the default hcl path to use for the Terragrunt configuration file in the given directory
func DefaultJsonConfigPath ¶ added in v0.21.6
Return the default path to use for the Terragrunt Json configuration file in the given directory
func FindConfigFilesInPath ¶ added in v0.10.0
func FindConfigFilesInPath(rootPath string, terragruntOptions *options.TerragruntOptions) ([]string, error)
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
func GetDefaultConfigPath ¶ added in v0.21.6
Return the default path to use for the Terragrunt configuration that exists within the path giving preference to `terragrunt.hcl`
Types ¶
type CouldNotEvaluateAllLocalsError ¶ added in v0.19.14
type CouldNotEvaluateAllLocalsError struct{}
func (CouldNotEvaluateAllLocalsError) Error ¶ added in v0.19.14
func (err CouldNotEvaluateAllLocalsError) Error() string
type CouldNotResolveTerragruntConfigInFile ¶ added in v0.10.0
type CouldNotResolveTerragruntConfigInFile string
func (CouldNotResolveTerragruntConfigInFile) Error ¶ added in v0.10.0
func (err CouldNotResolveTerragruntConfigInFile) Error() string
type CtyJsonOutput ¶ added in v0.19.0
type CtyJsonOutput struct { Value map[string]interface{} Type interface{} }
When you convert a cty value to JSON, if any of that types are not yet known (i.e., are labeled as DynamicPseudoType), cty's Marshall method will write the type information to a type field and the actual value to a value field. This struct is used to capture that information so when we parse the JSON back into a Go struct, we can pull out just the Value field we need.
type Dependency ¶ added in v0.19.20
type DependencyConfigNotFound ¶ added in v0.19.20
type DependencyConfigNotFound struct {
Path string
}
func (DependencyConfigNotFound) Error ¶ added in v0.19.20
func (err DependencyConfigNotFound) Error() string
type DependencyCycle ¶ added in v0.19.23
type DependencyCycle []string
func (DependencyCycle) Error ¶ added in v0.19.23
func (err DependencyCycle) Error() string
type EmptyStringNotAllowed ¶ added in v0.13.8
type EmptyStringNotAllowed string
func (EmptyStringNotAllowed) Error ¶ added in v0.13.8
func (err EmptyStringNotAllowed) Error() string
type ErrorParsingTerragruntConfig ¶ added in v0.13.14
func (ErrorParsingTerragruntConfig) Error ¶ added in v0.13.14
func (err ErrorParsingTerragruntConfig) Error() string
type EvalContextExtensions ¶ added in v0.19.20
type EvalContextExtensions struct { // Include is used to specify another config that should be imported and merged before the final TerragruntConfig is // returned. Include *IncludeConfig // Locals are preevaluated variable bindings that can be used by reference in the code. Locals *cty.Value // DecodedDependencies are references of other terragrunt config. This contains the following attributes that map to // various fields related to that config: // - outputs: The map of outputs from the terraform state obtained by running `terragrunt output` on that target // config. DecodedDependencies *cty.Value }
EvalContextExtensions provides various extensions to the evaluation context to enhance the parsing capabilities.
type Hook ¶ added in v0.14.4
type Hook struct { Name string `hcl:"name,label"` Commands []string `hcl:"commands,attr"` Execute []string `hcl:"execute,attr"` RunOnError *bool `hcl:"run_on_error,attr"` }
Hook specifies terraform commands (apply/plan) and array of os commands to execute
type IncludeConfig ¶ added in v0.4.0
type IncludeConfig struct {
Path string `hcl:"path,attr"`
}
IncludeConfig represents the configuration settings for a parent Terragrunt configuration file that you can "include" in a child Terragrunt configuration file
func DecodeBaseBlocks ¶ added in v0.19.20
func DecodeBaseBlocks( terragruntOptions *options.TerragruntOptions, parser *hclparse.Parser, hclFile *hcl.File, filename string, includeFromChild *IncludeConfig, ) (*cty.Value, *terragruntInclude, *IncludeConfig, error)
DecodeBaseBlocks takes in a parsed HCL2 file and decodes the base blocks. Base blocks are blocks that should always be decoded even in partial decoding, because they provide bindings that are necessary for parsing any block in the file. Currently base blocks are: - locals - include
func (*IncludeConfig) String ¶ added in v0.19.0
func (cfg *IncludeConfig) String() string
type IncludedConfigMissingPath ¶ added in v0.4.0
type IncludedConfigMissingPath string
func (IncludedConfigMissingPath) Error ¶ added in v0.4.0
func (err IncludedConfigMissingPath) Error() string
type InvalidArgError ¶ added in v0.14.4
type InvalidArgError string
func (InvalidArgError) Error ¶ added in v0.14.4
func (e InvalidArgError) Error() string
type InvalidBackendConfigType ¶ added in v0.19.0
func (InvalidBackendConfigType) Error ¶ added in v0.19.0
func (err InvalidBackendConfigType) Error() string
type InvalidGetEnvParams ¶ added in v0.13.8
func (InvalidGetEnvParams) Error ¶ added in v0.13.8
func (err InvalidGetEnvParams) Error() string
type InvalidParameterType ¶ added in v0.19.0
func (InvalidParameterType) Error ¶ added in v0.19.0
func (err InvalidParameterType) Error() string
type InvalidPartialBlockName ¶ added in v0.19.20
type InvalidPartialBlockName struct {
// contains filtered or unexported fields
}
func (InvalidPartialBlockName) Error ¶ added in v0.19.20
func (err InvalidPartialBlockName) Error() string
type Local ¶ added in v0.19.14
type Local struct { Name string Expr hcl.Expression }
Local represents a single local name binding. This holds the unevaluated expression, extracted from the parsed file (but before decoding) so that we can look for references to other locals before evaluating.
type MaxIterError ¶ added in v0.19.14
type MaxIterError struct{}
func (MaxIterError) Error ¶ added in v0.19.14
func (err MaxIterError) Error() string
type ModuleDependencies ¶ added in v0.6.0
type ModuleDependencies struct {
Paths []string `hcl:"paths,attr"`
}
ModuleDependencies represents the paths to other Terraform modules that must be applied before the current module can be applied
func (*ModuleDependencies) Merge ¶ added in v0.19.20
func (deps *ModuleDependencies) Merge(source *ModuleDependencies)
Merge appends the paths in the provided ModuleDependencies object into this ModuleDependencies object.
func (*ModuleDependencies) String ¶ added in v0.9.4
func (deps *ModuleDependencies) String() string
type PanicWhileParsingConfig ¶ added in v0.19.0
type PanicWhileParsingConfig struct { ConfigFile string RecoveredValue interface{} }
func (PanicWhileParsingConfig) Error ¶ added in v0.19.0
func (err PanicWhileParsingConfig) Error() string
type ParentFileNotFound ¶ added in v0.13.8
func (ParentFileNotFound) Error ¶ added in v0.13.8
func (err ParentFileNotFound) Error() string
type PartialDecodeSectionType ¶ added in v0.19.20
type PartialDecodeSectionType int
PartialDecodeSectionType is an enum that is used to list out which blocks/sections of the terragrunt config should be decoded in a partial decode.
const ( DependenciesBlock PartialDecodeSectionType = iota DependencyBlock TerraformBlock TerragruntFlags )
type TerraformConfig ¶ added in v0.9.4
type TerraformConfig struct { ExtraArgs []TerraformExtraArguments `hcl:"extra_arguments,block"` Source *string `hcl:"source,attr"` BeforeHooks []Hook `hcl:"before_hook,block"` AfterHooks []Hook `hcl:"after_hook,block"` }
TerraformConfig specifies where to find the Terraform configuration files
func (*TerraformConfig) GetAfterHooks ¶ added in v0.14.4
func (conf *TerraformConfig) GetAfterHooks() []Hook
func (*TerraformConfig) GetBeforeHooks ¶ added in v0.14.4
func (conf *TerraformConfig) GetBeforeHooks() []Hook
func (*TerraformConfig) String ¶ added in v0.9.4
func (conf *TerraformConfig) String() string
func (*TerraformConfig) ValidateHooks ¶ added in v0.14.4
func (conf *TerraformConfig) ValidateHooks() error
type TerraformExtraArguments ¶ added in v0.10.2
type TerraformExtraArguments struct { Name string `hcl:"name,label"` Arguments *[]string `hcl:"arguments,attr"` RequiredVarFiles *[]string `hcl:"required_var_files,attr"` OptionalVarFiles *[]string `hcl:"optional_var_files,attr"` Commands []string `hcl:"commands,attr"` EnvVars *map[string]string `hcl:"env_vars,attr"` }
TerraformExtraArguments sets a list of arguments to pass to Terraform if command fits any in the `Commands` list
func (*TerraformExtraArguments) String ¶ added in v0.10.2
func (conf *TerraformExtraArguments) String() string
type TerragruntConfig ¶
type TerragruntConfig struct { Terraform *TerraformConfig TerraformBinary string TerraformVersionConstraint string RemoteState *remote.RemoteState Dependencies *ModuleDependencies DownloadDir string PreventDestroy bool Skip bool IamRole string Inputs map[string]interface{} Locals map[string]interface{} TerragruntDependencies []Dependency GenerateConfigs map[string]codegen.GenerateConfig // Indicates whether or not this is the result of a partial evaluation IsPartial bool }
TerragruntConfig represents a parsed and expanded configuration
func ParseConfigFile ¶ added in v0.6.0
func ParseConfigFile(filename string, terragruntOptions *options.TerragruntOptions, include *IncludeConfig) (*TerragruntConfig, error)
Parse 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 ParseConfigString ¶ added in v0.19.0
func ParseConfigString(configString string, terragruntOptions *options.TerragruntOptions, includeFromChild *IncludeConfig, filename string) (*TerragruntConfig, error)
Parse the Terragrunt config contained in the given string and merge it with the given include config (if any). Note that the config parsing consists of multiple stages so as to allow referencing of data resulting from parsing previous config. The parsing order is:
- Parse include. Include is parsed first and is used to import another config. All the config in the include block is then merged into the current TerragruntConfig, except for locals (by design). Note that since the include block is parsed first, you cannot reference locals in the include block config.
- Parse locals. Since locals are parsed next, you can only reference other locals in the locals block. Although it is possible to merge locals from a config imported with an include block, we do not do that here to avoid complicated referencing issues. Please refer to the globals proposal for an alternative that allows merging from included config: https://github.com/gruntwork-io/terragrunt/issues/814 Allowed References: - locals
- Parse dependency blocks. This includes running `terragrunt output` to fetch the output data from another terragrunt config, so that it is accessible within the config. See PartialParseConfigString for a way to parse the blocks but avoid decoding. Allowed References: - locals
- Parse everything else. At this point, all the necessary building blocks for parsing the rest of the config are available, so parse the rest of the config. Allowed References: - locals - dependency
- Merge the included config with the parsed config. Note that all the config data is mergable except for `locals` blocks, which are only scoped to be available within the defining config.
func PartialParseConfigFile ¶ added in v0.19.20
func PartialParseConfigFile( filename string, terragruntOptions *options.TerragruntOptions, include *IncludeConfig, decodeList []PartialDecodeSectionType, ) (*TerragruntConfig, error)
func PartialParseConfigString ¶ added in v0.19.20
func PartialParseConfigString( configString string, terragruntOptions *options.TerragruntOptions, includeFromChild *IncludeConfig, filename string, decodeList []PartialDecodeSectionType, ) (*TerragruntConfig, error)
ParitalParseConfigString partially parses and decodes the provided string. Which blocks/attributes to decode is controlled by the function parameter decodeList. These blocks/attributes are parsed and set on the output TerragruntConfig. Valid values are: - DependenciesBlock: Parses the `dependencies` block in the config - DependencyBlock: Parses the `dependency` block in the config - TerraformBlock: Parses the `terraform` block in the config - TerragruntFlags: Parses the boolean flags `prevent_destroy` and `skip` in the config Note that the following blocks are always decoded: - locals - include Note also that the following blocks are never decoded in a partial parse: - inputs
func ReadTerragruntConfig ¶
func ReadTerragruntConfig(terragruntOptions *options.TerragruntOptions) (*TerragruntConfig, error)
Read the Terragrunt config file from its default location
func (*TerragruntConfig) String ¶ added in v0.9.4
func (conf *TerragruntConfig) String() string
type TerragruntOutputEncodingError ¶ added in v0.19.20
func (TerragruntOutputEncodingError) Error ¶ added in v0.19.20
func (err TerragruntOutputEncodingError) Error() string
type TerragruntOutputListEncodingError ¶ added in v0.19.20
func (TerragruntOutputListEncodingError) Error ¶ added in v0.19.20
func (err TerragruntOutputListEncodingError) Error() string
type TerragruntOutputParsingError ¶ added in v0.19.20
func (TerragruntOutputParsingError) Error ¶ added in v0.19.20
func (err TerragruntOutputParsingError) Error() string
type TerragruntOutputTargetNoOutputs ¶ added in v0.19.23
type TerragruntOutputTargetNoOutputs struct {
// contains filtered or unexported fields
}
func (TerragruntOutputTargetNoOutputs) Error ¶ added in v0.19.23
func (err TerragruntOutputTargetNoOutputs) Error() string
type TooManyLevelsOfInheritance ¶ added in v0.4.0
type TooManyLevelsOfInheritance struct { ConfigPath string FirstLevelIncludePath string SecondLevelIncludePath string }
func (TooManyLevelsOfInheritance) Error ¶ added in v0.4.0
func (err TooManyLevelsOfInheritance) Error() string
type WrongNumberOfParams ¶ added in v0.19.0
Custom error types
func (WrongNumberOfParams) Error ¶ added in v0.19.0
func (err WrongNumberOfParams) Error() string