Documentation ¶
Overview ¶
Package config provides functionality for parsing Terragrunt configuration files.
Index ¶
- Constants
- Variables
- func ClearOutputCache()
- func CopyFieldsMetadata(sourceConfig *TerragruntConfig, targetConfig *TerragruntConfig)
- func CopyLockFile(opts *options.TerragruntOptions, sourceFolder, destinationFolder string) error
- func CtyToStruct(ctyValue cty.Value, target interface{}) error
- func EndsWith(ctx *ParsingContext, args []string) (bool, error)
- func EvaluateLocalsBlock(ctx *ParsingContext, file *hclparse.File) (map[string]cty.Value, error)
- func FindConfigFilesInPath(rootPath string, opts *options.TerragruntOptions) ([]string, error)
- func FindInParentFolders(ctx *ParsingContext, params []string) (string, error)
- func GetDefaultConfigPath(workingDir string) string
- func GetParentTerragruntDir(ctx *ParsingContext, params []string) (string, error)
- func GetTerraformSourceURL(terragruntOptions *options.TerragruntOptions, ...) (string, error)
- func GetTerragruntDir(ctx *ParsingContext) (string, error)
- func GetTerragruntSourceForModule(sourcePath string, modulePath string, moduleTerragruntConfig *TerragruntConfig) (string, error)
- func ParseAndDecodeVarFile(opts *options.TerragruntOptions, varFile string, fileContents []byte, ...) error
- func ParseCtyValueToMap(value cty.Value) (map[string]interface{}, error)
- func ParseTerragruntConfig(ctx *ParsingContext, configPath string, defaultVal *cty.Value) (cty.Value, error)
- func PathRelativeFromInclude(ctx *ParsingContext, params []string) (string, error)
- func PathRelativeToInclude(ctx *ParsingContext, params []string) (string, error)
- func RemoteStateAsCty(remoteState *remote.RemoteState) (cty.Value, error)
- func RunCommand(ctx *ParsingContext, args []string) (string, error)
- func StartsWith(ctx *ParsingContext, args []string) (bool, error)
- func StrContains(ctx *ParsingContext, args []string) (bool, error)
- func TerraformOutputJSONToCtyValueMap(targetConfigPath string, jsonBytes []byte) (map[string]cty.Value, error)
- func TerragruntConfigAsCty(config *TerragruntConfig) (cty.Value, error)
- func TerragruntConfigAsCtyWithMetadata(config *TerragruntConfig) (cty.Value, error)
- func TimeCmp(ctx *ParsingContext, args []string) (int64, error)
- func UpdateUnknownCtyValValues(value cty.Value) (cty.Value, error)
- func WithConfigValues(ctx context.Context) context.Context
- type CatalogConfig
- type CouldNotEvaluateAllLocalsError
- type CouldNotResolveTerragruntConfigInFileError
- type CtyJSONOutput
- type CtyTerraformConfig
- type DecodedBaseBlocks
- type Dependencies
- type Dependency
- type DependencyConfigNotFound
- type DependencyCycleError
- type DependencyDirNotFoundError
- type DuplicatedGenerateBlocksError
- type EmptyStringNotAllowedError
- type EngineConfig
- type EnvVar
- type EnvVarNotFoundError
- type ErrorHook
- type ErrorsConfig
- type ExcludeConfig
- type FeatureFlag
- type FeatureFlags
- type Hook
- type IgnoreBlock
- type IncludeConfig
- type IncludeConfigs
- type IncludeConfigsMap
- type IncludeIsNotABlockErr
- type IncludedConfigMissingPathError
- type InvalidArgError
- type InvalidEnvParamNameError
- type InvalidGetEnvParamsError
- type InvalidIncludeKeyError
- type InvalidMergeStrategyTypeError
- type InvalidParameterTypeError
- type InvalidPartialBlockName
- type InvalidSopsFormatError
- type InvalidSourceURLError
- type InvalidSourceURLWithMapError
- type MaxIterError
- type MergeStrategyType
- type ModuleDependencies
- type MultipleBareIncludeBlocksErr
- type ParentFileNotFoundError
- type ParsedVariable
- type ParsingContext
- func (ctx ParsingContext) WithDecodeList(decodeList ...PartialDecodeSectionType) *ParsingContext
- func (ctx ParsingContext) WithFeatures(features *cty.Value) *ParsingContext
- func (ctx ParsingContext) WithLocals(locals *cty.Value) *ParsingContext
- func (ctx ParsingContext) WithParseOption(parserOptions []hclparse.Option) *ParsingContext
- func (ctx ParsingContext) WithTerragruntOptions(opts *options.TerragruntOptions) *ParsingContext
- func (ctx ParsingContext) WithTrackInclude(trackInclude *TrackInclude) *ParsingContext
- type ParsingModulePathError
- type PartialDecodeSectionType
- type RetryBlock
- type TFVarFileNotFoundError
- type TerraformConfig
- type TerraformExtraArguments
- type TerragruntConfig
- func ParseConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
- func ParseConfigFile(ctx *ParsingContext, configPath string, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
- func ParseConfigString(ctx *ParsingContext, configPath string, configString string, ...) (*TerragruntConfig, error)
- func PartialParseConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
- func PartialParseConfigFile(ctx *ParsingContext, configPath string, include *IncludeConfig) (*TerragruntConfig, error)
- func PartialParseConfigString(ctx *ParsingContext, configPath, configString string, include *IncludeConfig) (*TerragruntConfig, error)
- func ReadTerragruntConfig(ctx context.Context, terragruntOptions *options.TerragruntOptions, ...) (*TerragruntConfig, error)
- func TerragruntConfigFromPartialConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
- func (cfg *TerragruntConfig) DeepMerge(sourceConfig *TerragruntConfig, terragruntOptions *options.TerragruntOptions) error
- func (cfg *TerragruntConfig) EngineOptions() (*options.EngineOptions, error)
- func (cfg *TerragruntConfig) ErrorsConfig() (*options.ErrorsConfig, error)
- func (cfg *TerragruntConfig) GetFieldMetadata(fieldName string) (map[string]string, bool)
- func (cfg *TerragruntConfig) GetIAMRoleOptions() options.IAMRoleOptions
- func (cfg *TerragruntConfig) GetMapFieldMetadata(fieldType, fieldName string) (map[string]string, bool)
- func (cfg *TerragruntConfig) Merge(sourceConfig *TerragruntConfig, terragruntOptions *options.TerragruntOptions) error
- func (cfg *TerragruntConfig) SetFieldMetadata(fieldName string, m map[string]interface{})
- func (cfg *TerragruntConfig) SetFieldMetadataMap(field string, data map[string]interface{}, metadata map[string]interface{})
- func (cfg *TerragruntConfig) SetFieldMetadataWithType(fieldType, fieldName string, m map[string]interface{})
- func (cfg *TerragruntConfig) String() string
- type TerragruntConfigNotFoundError
- type TerragruntDependency
- type TerragruntOutputEncodingError
- type TerragruntOutputListEncodingError
- type TerragruntOutputParsingError
- type TerragruntOutputTargetNoOutputs
- type TooManyLevelsOfInheritanceError
- type TrackInclude
- type ValueWithMetadata
- type WrongNumberOfParamsError
Constants ¶
const ( DefaultTerragruntConfigPath = "terragrunt.hcl" DefaultTerragruntJSONConfigPath = "terragrunt.hcl.json" FoundInFile = "found_in_file" DefaultEngineType = "rpc" MetadataTerraform = "terraform" MetadataTerraformBinary = "terraform_binary" MetadataTerraformVersionConstraint = "terraform_version_constraint" MetadataTerragruntVersionConstraint = "terragrunt_version_constraint" MetadataRemoteState = "remote_state" MetadataDependencies = "dependencies" MetadataDependency = "dependency" MetadataDownloadDir = "download_dir" MetadataPreventDestroy = "prevent_destroy" MetadataSkip = "skip" MetadataIamRole = "iam_role" MetadataIamAssumeRoleDuration = "iam_assume_role_duration" MetadataIamAssumeRoleSessionName = "iam_assume_role_session_name" MetadataIamWebIdentityToken = "iam_web_identity_token" MetadataInputs = "inputs" MetadataLocals = "locals" MetadataLocal = "local" MetadataCatalog = "catalog" MetadataEngine = "engine" MetadataGenerateConfigs = "generate" MetadataRetryableErrors = "retryable_errors" MetadataRetryMaxAttempts = "retry_max_attempts" MetadataRetrySleepIntervalSec = "retry_sleep_interval_sec" MetadataDependentModules = "dependent_modules" MetadataInclude = "include" MetadataFeatureFlag = "feature" MetadataExclude = "exclude" MetadataErrors = "errors" MetadataRetry = "retry" MetadataIgnore = "ignore" )
const ( FuncNameFindInParentFolders = "find_in_parent_folders" FuncNamePathRelativeToInclude = "path_relative_to_include" FuncNamePathRelativeFromInclude = "path_relative_from_include" FuncNameGetEnv = "get_env" FuncNameRunCmd = "run_cmd" FuncNameReadTerragruntConfig = "read_terragrunt_config" FuncNameGetPlatform = "get_platform" FuncNameGetRepoRoot = "get_repo_root" FuncNameGetPathFromRepoRoot = "get_path_from_repo_root" FuncNameGetPathToRepoRoot = "get_path_to_repo_root" FuncNameGetTerragruntDir = "get_terragrunt_dir" FuncNameGetOriginalTerragruntDir = "get_original_terragrunt_dir" FuncNameGetTerraformCommand = "get_terraform_command" FuncNameGetTerraformCLIArgs = "get_terraform_cli_args" FuncNameGetParentTerragruntDir = "get_parent_terragrunt_dir" FuncNameGetAWSAccountAlias = "get_aws_account_alias" FuncNameGetAWSAccountID = "get_aws_account_id" FuncNameGetAWSCallerIdentityArn = "get_aws_caller_identity_arn" FuncNameGetAWSCallerIdentityUserID = "get_aws_caller_identity_user_id" FuncNameGetTerraformCommandsThatNeedVars = "get_terraform_commands_that_need_vars" FuncNameGetTerraformCommandsThatNeedLocking = "get_terraform_commands_that_need_locking" FuncNameGetTerraformCommandsThatNeedInput = "get_terraform_commands_that_need_input" FuncNameGetTerraformCommandsThatNeedParallelism = "get_terraform_commands_that_need_parallelism" FuncNameSopsDecryptFile = "sops_decrypt_file" FuncNameGetTerragruntSourceCLIFlag = "get_terragrunt_source_cli_flag" FuncNameGetDefaultRetryableErrors = "get_default_retryable_errors" FuncNameReadTfvarsFile = "read_tfvars_file" FuncNameGetWorkingDir = "get_working_dir" FuncNameStartsWith = "startswith" FuncNameEndsWith = "endswith" FuncNameStrContains = "strcontains" FuncNameTimeCmp = "timecmp" FuncNameMarkAsRead = "mark_as_read" )
const ( HclCacheContextKey configKey = iota TerragruntConfigCacheContextKey configKey = iota RunCmdCacheContextKey configKey = iota DependencyOutputCacheContextKey configKey = iota )
const MaxIter = 1000
MaxIter is the maximum number of depth we support in recursively evaluating locals.
Variables ¶
var ( // Order matters, for example if none of the files are found `GetDefaultConfigPath` func returns the last element. DefaultTerragruntConfigPaths = []string{ DefaultTerragruntJSONConfigPath, DefaultTerragruntConfigPath, } DefaultParserOptions = func(opts *options.TerragruntOptions) []hclparse.Option { writer := writer.New(writer.WithLogger(opts.Logger), writer.WithDefaultLevel(log.ErrorLevel)) return []hclparse.Option{ hclparse.WithDiagnosticsWriter(writer, opts.DisableLogColors), hclparse.WithFileUpdate(updateBareIncludeBlock), hclparse.WithLogger(opts.Logger), } } DefaultGenerateBlockIfDisabledValueStr = codegen.DisabledSkipStr )
var TerraformCommandsNeedInput = []string{
"apply",
"import",
"init",
"plan",
"refresh",
}
TerraformCommandsNeedInput is list of terraform commands that accept -input=
var TerraformCommandsNeedLocking = []string{
"apply",
"destroy",
"import",
"plan",
"refresh",
"taint",
"untaint",
}
TerraformCommandsNeedLocking is a list of terraform commands that accept -lock-timeout
var TerraformCommandsNeedParallelism = []string{
"apply",
"plan",
"destroy",
}
TerraformCommandsNeedParallelism is a list of terraform commands that accept -parallelism=
var TerraformCommandsNeedVars = []string{
"apply",
"console",
"destroy",
"import",
"plan",
"push",
"refresh",
}
TerraformCommandsNeedVars is a 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 CopyFieldsMetadata ¶ added in v0.66.7
func CopyFieldsMetadata(sourceConfig *TerragruntConfig, targetConfig *TerragruntConfig)
CopyFieldsMetadata Copy fields metadata between TerragruntConfig instances.
func CopyLockFile ¶ added in v0.67.0
func CopyLockFile(opts *options.TerragruntOptions, sourceFolder, destinationFolder string) error
CopyLockFile copies the lock file from the source folder to the destination folder.
Terraform 0.14 now generates a lock file when you run `terraform init`. If any such file exists, this function will copy the lock file to the destination folder
func CtyToStruct ¶ added in v0.68.16
CtyToStruct converts a cty.Value to a go struct.
func EndsWith ¶ added in v0.66.7
func EndsWith(ctx *ParsingContext, args []string) (bool, error)
EndsWith Implementation of Terraform's EndsWith function
func EvaluateLocalsBlock ¶ added in v0.66.7
EvaluateLocalsBlock is a routine to evaluate the locals block in a way to allow references to other locals. This will:
- Extract a reference to the locals block from the parsed file
- Continuously evaluate the block until all references are evaluated, deferring evaluation of anything that references other locals until those references are evaluated.
This returns a map of the local names to the evaluated expressions (represented as `cty.Value` objects). This will error if there are remaining unevaluated locals after all references that can be evaluated has been evaluated.
func FindConfigFilesInPath ¶ added in v0.10.0
func FindConfigFilesInPath(rootPath string, opts *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
func FindInParentFolders ¶ added in v0.54.5
func FindInParentFolders( ctx *ParsingContext, params []string, ) (string, error)
FindInParentFolders fings a parent Terragrunt configuration file in the parent folders above the current Terragrunt configuration file and return its path.
func GetDefaultConfigPath ¶ added in v0.21.6
GetDefaultConfigPath returns the default path to use for the Terragrunt configuration that exists within the path giving preference to `terragrunt.hcl`
func GetParentTerragruntDir ¶ added in v0.66.7
func GetParentTerragruntDir(ctx *ParsingContext, params []string) (string, error)
GetParentTerragruntDir returns the parent directory where the Terragrunt configuration file lives.
func GetTerraformSourceURL ¶ added in v0.67.7
func GetTerraformSourceURL(terragruntOptions *options.TerragruntOptions, terragruntConfig *TerragruntConfig) (string, error)
GetTerraformSourceURL returns the source URL for OpenTofu/Terraform configuration.
There are two ways a user can tell Terragrunt that it needs to download Terraform configurations from a specific URL: via a command-line option or via an entry in the Terragrunt configuration. If the user used one of these, this method returns the source URL or an empty string if there is no source url
func GetTerragruntDir ¶ added in v0.66.7
func GetTerragruntDir(ctx *ParsingContext) (string, error)
GetTerragruntDir returns the directory where the Terragrunt configuration file lives.
func GetTerragruntSourceForModule ¶ added in v0.23.9
func GetTerragruntSourceForModule(sourcePath string, modulePath string, moduleTerragruntConfig *TerragruntConfig) (string, error)
GetTerragruntSourceForModule returns the source path for a module based on the source path of the parent module and the source path specified in the module's terragrunt.hcl file.
If one of the xxx-all commands is called with the --terragrunt-source parameter, then for each module, we need to build its own --terragrunt-source parameter by doing the following:
1. Read the source URL from the Terragrunt configuration of each module 2. Extract the path from that URL (the part after a double-slash) 3. Append the path to the --terragrunt-source parameter
Example:
--terragrunt-source: /source/infrastructure-modules source param in module's terragrunt.hcl: git::git@github.com:acme/infrastructure-modules.git//networking/vpc?ref=v0.0.1
This method will return: /source/infrastructure-modules//networking/vpc
func ParseAndDecodeVarFile ¶ added in v0.28.11
func ParseAndDecodeVarFile(opts *options.TerragruntOptions, varFile string, fileContents []byte, out interface{}) error
ParseAndDecodeVarFile uses the HCL2 file to parse the given varfile string into an HCL file body, and then decode it into the provided output.
func ParseCtyValueToMap ¶ added in v0.66.7
ParseCtyValueToMap converts a cty.Value to a map[string]interface{}.
This is a hacky workaround to convert a cty Value to a Go map[string]interface{}. cty does not support this directly (https://github.com/hashicorp/hcl2/issues/108) and doing it with gocty.FromCtyValue is nearly impossible, as cty requires you to specify all the output types and will error out when it hits interface{}. So, as an ugly workaround, we convert the given value to JSON using cty's JSON library and then convert the JSON back to a map[string]interface{} using the Go json library.
func ParseTerragruntConfig ¶ added in v0.66.7
func ParseTerragruntConfig(ctx *ParsingContext, configPath string, defaultVal *cty.Value) (cty.Value, error)
ParseTerragruntConfig parses the terragrunt config and return a representation that can be used as a reference. If given a default value, this will return the default if the terragrunt config file does not exist.
func PathRelativeFromInclude ¶ added in v0.66.7
func PathRelativeFromInclude(ctx *ParsingContext, params []string) (string, error)
PathRelativeFromInclude returns the relative path from the current Terragrunt configuration to the included Terragrunt configuration file
func PathRelativeToInclude ¶ added in v0.66.7
func PathRelativeToInclude(ctx *ParsingContext, params []string) (string, error)
PathRelativeToInclude returns the relative path between the included Terragrunt configuration file and the current Terragrunt configuration file. Name param is required and used to lookup the relevant import block when called in a child config with multiple import blocks.
func RemoteStateAsCty ¶ added in v0.66.7
func RemoteStateAsCty(remoteState *remote.RemoteState) (cty.Value, error)
RemoteStateAsCty serializes RemoteState to a cty Value. We can't directly serialize the struct because `config` is an arbitrary interface whose type we do not know, so we have to do a hack to go through json.
func RunCommand ¶ added in v0.66.7
func RunCommand(ctx *ParsingContext, args []string) (string, error)
RunCommand is a helper function that runs a command and returns the stdout as the interpolation for each `run_cmd` in locals section, function is called twice result
func StartsWith ¶ added in v0.66.7
func StartsWith(ctx *ParsingContext, args []string) (bool, error)
StartsWith Implementation of Terraform's StartsWith function
func StrContains ¶ added in v0.66.7
func StrContains(ctx *ParsingContext, args []string) (bool, error)
StrContains Implementation of Terraform's StrContains function
func TerraformOutputJSONToCtyValueMap ¶ added in v0.67.7
func TerraformOutputJSONToCtyValueMap(targetConfigPath string, jsonBytes []byte) (map[string]cty.Value, error)
TerraformOutputJSONToCtyValueMap takes the terraform output json and converts to a mapping between output keys to the parsed cty.Value encoding of the json objects.
func TerragruntConfigAsCty ¶ added in v0.33.2
func TerragruntConfigAsCty(config *TerragruntConfig) (cty.Value, error)
TerragruntConfigAsCty serializes TerragruntConfig struct to a cty Value that can be used to reference the attributes in other config. Note that we can't straight up convert the struct using cty tags due to differences in the desired representation. Specifically, we want to reference blocks by named attributes, but blocks are rendered to lists in the TerragruntConfig struct, so we need to do some massaging of the data to convert the list of blocks in to a map going from the block name label to the block value.
func TerragruntConfigAsCtyWithMetadata ¶ added in v0.38.6
func TerragruntConfigAsCtyWithMetadata(config *TerragruntConfig) (cty.Value, error)
func TimeCmp ¶ added in v0.66.7
func TimeCmp(ctx *ParsingContext, args []string) (int64, error)
TimeCmp implements Terraform's `timecmp` function that compares two timestamps.
func UpdateUnknownCtyValValues ¶ added in v0.66.7
UpdateUnknownCtyValValues deeply updates unknown values with default value
Types ¶
type CatalogConfig ¶ added in v0.54.5
type CatalogConfig struct {
URLs []string `hcl:"urls,attr" cty:"urls"`
}
func ReadCatalogConfig ¶ added in v0.54.9
func ReadCatalogConfig(parentCtx context.Context, opts *options.TerragruntOptions) (*CatalogConfig, error)
ReadCatalogConfig reads the `catalog` block from the nearest `terragrunt.hcl` file in the parent directories.
We want users to be able to browse to any folder in an `infra-live` repo, run `terragrunt catalog` (with no URL) arg. ReadCatalogConfig looks for the "nearest" `terragrunt.hcl` in the parent directories if the given `opts.TerragruntConfigPath` does not exist. Since our normal parsing `ParseConfig` does not always work, as some `terragrunt.hcl` files are meant to be used from an `include` and/or they might use `find_in_parent_folders` and they only work from certain child folders, it parses this file to see if the config contains `include{...find_in_parent_folders()...}` block to determine if it is the root configuration. If it finds `terragrunt.hcl` that already has `include`, then read that configuration as is, otherwise generate a stub child `terragrunt.hcl` in memory with an `include` to pull in the one we found. Unlike the "ReadTerragruntConfig" func, it ignores any configuration errors not related to the "catalog" block.
func (*CatalogConfig) String ¶ added in v0.54.5
func (cfg *CatalogConfig) String() string
type CouldNotEvaluateAllLocalsError ¶ added in v0.19.14
type CouldNotEvaluateAllLocalsError struct {
Err error
}
func (CouldNotEvaluateAllLocalsError) Error ¶ added in v0.19.14
func (err CouldNotEvaluateAllLocalsError) Error() string
func (CouldNotEvaluateAllLocalsError) Unwrap ¶ added in v0.61.0
func (err CouldNotEvaluateAllLocalsError) Unwrap() error
type CouldNotResolveTerragruntConfigInFileError ¶ added in v0.54.16
type CouldNotResolveTerragruntConfigInFileError string
func (CouldNotResolveTerragruntConfigInFileError) Error ¶ added in v0.54.16
func (err CouldNotResolveTerragruntConfigInFileError) Error() string
type CtyJSONOutput ¶ added in v0.67.7
type CtyJSONOutput struct { Value map[string]interface{} `json:"Value"` Type interface{} `json:"Type"` }
CtyJSONOutput is a struct that captures the output of cty's JSON marshalling.
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 CtyTerraformConfig ¶ added in v0.66.7
type CtyTerraformConfig struct { ExtraArgs map[string]TerraformExtraArguments `cty:"extra_arguments"` Source *string `cty:"source"` IncludeInCopy *[]string `cty:"include_in_copy"` CopyTerraformLockFile *bool `cty:"copy_terraform_lock_file"` BeforeHooks map[string]Hook `cty:"before_hook"` AfterHooks map[string]Hook `cty:"after_hook"` ErrorHooks map[string]ErrorHook `cty:"error_hook"` }
CtyTerraformConfig is an alternate representation of TerraformConfig that converts internal blocks into a map that maps the name to the underlying struct, as opposed to a list representation.
type DecodedBaseBlocks ¶ added in v0.68.9
type DecodedBaseBlocks struct { TrackInclude *TrackInclude Locals *cty.Value FeatureFlags *cty.Value }
DecodedBaseBlocks decoded base blocks struct
func DecodeBaseBlocks ¶ added in v0.19.20
func DecodeBaseBlocks(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*DecodedBaseBlocks, 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 - features - include
type Dependencies ¶ added in v0.64.4
type Dependencies []Dependency
func (Dependencies) FilteredWithoutConfigPath ¶ added in v0.64.4
func (deps Dependencies) FilteredWithoutConfigPath() Dependencies
type Dependency ¶ added in v0.19.20
type Dependency struct { Name string `hcl:",label" cty:"name"` Enabled *bool `hcl:"enabled,attr" cty:"enabled"` ConfigPath cty.Value `hcl:"config_path,attr" cty:"config_path"` SkipOutputs *bool `hcl:"skip_outputs,attr" cty:"skip"` MockOutputs *cty.Value `hcl:"mock_outputs,attr" cty:"mock_outputs"` MockOutputsAllowedTerraformCommands *[]string `hcl:"mock_outputs_allowed_terraform_commands,attr" cty:"mock_outputs_allowed_terraform_commands"` // MockOutputsMergeWithState is deprecated. Use MockOutputsMergeStrategyWithState MockOutputsMergeWithState *bool `hcl:"mock_outputs_merge_with_state,attr" cty:"mock_outputs_merge_with_state"` MockOutputsMergeStrategyWithState *MergeStrategyType `hcl:"mock_outputs_merge_strategy_with_state" cty:"mock_outputs_merge_strategy_with_state"` // Used to store the rendered outputs for use when the config is imported or read with `read_terragrunt_config` RenderedOutputs *cty.Value `cty:"outputs"` Inputs *cty.Value `cty:"inputs"` }
func (*Dependency) DeepMerge ¶ added in v0.31.4
func (dep *Dependency) DeepMerge(sourceDepConfig Dependency) error
DeepMerge will deep merge two Dependency configs, updating the target. Deep merge for Dependency configs is defined as follows:
- For simple attributes (bools and strings), the source will override the target.
- For MockOutputs, the two maps will be deeply merged together. This means that maps are recursively merged, while lists are concatenated together.
- For MockOutputsAllowedTerraformCommands, the source will be concatenated to the target.
Note that RenderedOutputs is ignored in the deep merge operation.
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 DependencyCycleError ¶ added in v0.61.0
type DependencyCycleError []string
func (DependencyCycleError) Error ¶ added in v0.61.0
func (err DependencyCycleError) Error() string
type DependencyDirNotFoundError ¶ added in v0.54.16
type DependencyDirNotFoundError struct {
Dir []string
}
func (DependencyDirNotFoundError) Error ¶ added in v0.54.16
func (err DependencyDirNotFoundError) Error() string
type DuplicatedGenerateBlocksError ¶ added in v0.54.16
type DuplicatedGenerateBlocksError struct {
BlockName []string
}
func (DuplicatedGenerateBlocksError) Error ¶ added in v0.54.16
func (err DuplicatedGenerateBlocksError) Error() string
type EmptyStringNotAllowedError ¶ added in v0.54.16
type EmptyStringNotAllowedError string
func (EmptyStringNotAllowedError) Error ¶ added in v0.54.16
func (err EmptyStringNotAllowedError) Error() string
type EngineConfig ¶ added in v0.62.0
type EngineConfig struct { Source string `hcl:"source,attr" cty:"source"` Version *string `hcl:"version,attr" cty:"version"` Type *string `hcl:"type,attr" cty:"type"` Meta *cty.Value `hcl:"meta,attr" cty:"meta"` }
EngineConfig represents the structure of the HCL data
func (*EngineConfig) Clone ¶ added in v0.62.0
func (c *EngineConfig) Clone() *EngineConfig
Clone returns a copy of the EngineConfig used in deep copy
func (*EngineConfig) Merge ¶ added in v0.62.0
func (c *EngineConfig) Merge(engine *EngineConfig)
Merge merges the EngineConfig with another EngineConfig
type EnvVarNotFoundError ¶ added in v0.54.16
type EnvVarNotFoundError struct {
EnvVar string
}
func (EnvVarNotFoundError) Error ¶ added in v0.54.16
func (err EnvVarNotFoundError) Error() string
type ErrorHook ¶ added in v0.35.20
type ErrorHook struct { Name string `hcl:"name,label" cty:"name"` Commands []string `hcl:"commands,attr" cty:"commands"` Execute []string `hcl:"execute,attr" cty:"execute"` OnErrors []string `hcl:"on_errors,attr" cty:"on_errors"` SuppressStdout *bool `hcl:"suppress_stdout,attr" cty:"suppress_stdout"` WorkingDir *string `hcl:"working_dir,attr" cty:"working_dir"` }
type ErrorsConfig ¶ added in v0.69.6
type ErrorsConfig struct { Retry []*RetryBlock `cty:"retry" hcl:"retry,block"` Ignore []*IgnoreBlock `cty:"ignore" hcl:"ignore,block"` }
ErrorsConfig represents the top-level errors configuration
func (*ErrorsConfig) Clone ¶ added in v0.69.6
func (c *ErrorsConfig) Clone() *ErrorsConfig
Clone creates a deep copy of ErrorsConfig
func (*ErrorsConfig) Merge ¶ added in v0.69.6
func (c *ErrorsConfig) Merge(other *ErrorsConfig)
Merge combines the current ErrorsConfig with another one, with the other config taking precedence
type ExcludeConfig ¶ added in v0.68.16
type ExcludeConfig struct { If bool `cty:"if" hcl:"if,attr" json:"if"` Actions []string `cty:"actions" hcl:"actions,attr" json:"actions"` ExcludeDependencies *bool `cty:"exclude_dependencies" hcl:"exclude_dependencies,attr" json:"exclude_dependencies"` }
ExcludeConfig configurations for hcl files.
func (*ExcludeConfig) Clone ¶ added in v0.68.16
func (e *ExcludeConfig) Clone() *ExcludeConfig
Clone returns a new instance of ExcludeConfig with the same values as the original.
func (*ExcludeConfig) IsActionListed ¶ added in v0.68.16
func (e *ExcludeConfig) IsActionListed(action string) bool
IsActionListed checks if the action is listed in the exclude block.
func (*ExcludeConfig) Merge ¶ added in v0.68.16
func (e *ExcludeConfig) Merge(exclude *ExcludeConfig)
Merge merges the values of the provided ExcludeConfig into the original.
type FeatureFlag ¶ added in v0.68.9
type FeatureFlag struct { Name string `cty:"name" hcl:",label"` Default *cty.Value `cty:"default" hcl:"default,attr"` }
FeatureFlag feature flags struct.
func (*FeatureFlag) DeepMerge ¶ added in v0.68.9
func (feature *FeatureFlag) DeepMerge(source *FeatureFlag) error
DeepMerge merges the source FeatureFlag into the target FeatureFlag.
func (*FeatureFlag) DefaultAsString ¶ added in v0.68.9
func (feature *FeatureFlag) DefaultAsString() (string, error)
DefaultAsString returns the default value of the feature flag as a string.
type FeatureFlags ¶ added in v0.68.9
type FeatureFlags []*FeatureFlag
FeatureFlags represents a list of feature flags.
type Hook ¶ added in v0.14.4
type Hook struct { Name string `hcl:"name,label" cty:"name"` Commands []string `hcl:"commands,attr" cty:"commands"` Execute []string `hcl:"execute,attr" cty:"execute"` RunOnError *bool `hcl:"run_on_error,attr" cty:"run_on_error"` SuppressStdout *bool `hcl:"suppress_stdout,attr" cty:"suppress_stdout"` WorkingDir *string `hcl:"working_dir,attr" cty:"working_dir"` }
Hook specifies terraform commands (apply/plan) and array of os commands to execute
type IgnoreBlock ¶ added in v0.69.6
type IgnoreBlock struct { Label string `cty:"name" hcl:"name,label"` IgnorableErrors []string `cty:"ignorable_errors" hcl:"ignorable_errors"` Message string `cty:"message" hcl:"message,optional"` Signals map[string]cty.Value `cty:"signals" hcl:"signals,optional"` }
IgnoreBlock represents a labeled ignore block
func (*IgnoreBlock) Clone ¶ added in v0.69.6
func (i *IgnoreBlock) Clone() *IgnoreBlock
Clone creates a deep copy of IgnoreBlock
type IncludeConfig ¶ added in v0.4.0
type IncludeConfig struct { Name string `hcl:"name,label"` Path string `hcl:"path,attr"` Expose *bool `hcl:"expose,attr"` MergeStrategy *string `hcl:"merge_strategy,attr"` }
IncludeConfig represents the configuration settings for a parent Terragrunt configuration file that you can include into a child Terragrunt configuration file. You can have more than one include config.
func (*IncludeConfig) GetExpose ¶ added in v0.30.4
func (include *IncludeConfig) GetExpose() bool
func (*IncludeConfig) GetMergeStrategy ¶ added in v0.31.2
func (include *IncludeConfig) GetMergeStrategy() (MergeStrategyType, error)
func (*IncludeConfig) String ¶ added in v0.19.0
func (include *IncludeConfig) String() string
type IncludeConfigs ¶ added in v0.45.17
type IncludeConfigs []IncludeConfig
type IncludeConfigsMap ¶ added in v0.67.0
type IncludeConfigsMap map[string]IncludeConfig
func (IncludeConfigsMap) ContainsPath ¶ added in v0.67.0
func (cfgs IncludeConfigsMap) ContainsPath(path string) bool
ContainsPath returns true if the given path is contained in at least one configuration.
type IncludeIsNotABlockErr ¶ added in v0.32.0
type IncludeIsNotABlockErr struct {
// contains filtered or unexported fields
}
func (IncludeIsNotABlockErr) Error ¶ added in v0.32.0
func (err IncludeIsNotABlockErr) Error() string
type IncludedConfigMissingPathError ¶ added in v0.54.16
type IncludedConfigMissingPathError string
func (IncludedConfigMissingPathError) Error ¶ added in v0.54.16
func (err IncludedConfigMissingPathError) 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 InvalidEnvParamNameError ¶ added in v0.54.16
type InvalidEnvParamNameError struct {
EnvName string
}
func (InvalidEnvParamNameError) Error ¶ added in v0.54.16
func (err InvalidEnvParamNameError) Error() string
type InvalidGetEnvParamsError ¶ added in v0.54.16
func (InvalidGetEnvParamsError) Error ¶ added in v0.54.16
func (err InvalidGetEnvParamsError) Error() string
type InvalidIncludeKeyError ¶ added in v0.54.16
type InvalidIncludeKeyError struct {
// contains filtered or unexported fields
}
func (InvalidIncludeKeyError) Error ¶ added in v0.54.16
func (err InvalidIncludeKeyError) Error() string
type InvalidMergeStrategyTypeError ¶ added in v0.54.16
type InvalidMergeStrategyTypeError string
func (InvalidMergeStrategyTypeError) Error ¶ added in v0.54.16
func (err InvalidMergeStrategyTypeError) Error() string
type InvalidParameterTypeError ¶ added in v0.54.16
func (InvalidParameterTypeError) Error ¶ added in v0.54.16
func (err InvalidParameterTypeError) 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 InvalidSopsFormatError ¶ added in v0.54.16
type InvalidSopsFormatError struct {
SourceFilePath string
}
func (InvalidSopsFormatError) Error ¶ added in v0.54.16
func (err InvalidSopsFormatError) Error() string
type InvalidSourceURLError ¶ added in v0.67.7
type InvalidSourceURLError struct { ModulePath string ModuleSourceURL string TerragruntSource string }
func (InvalidSourceURLError) Error ¶ added in v0.67.7
func (err InvalidSourceURLError) Error() string
type InvalidSourceURLWithMapError ¶ added in v0.67.7
func (InvalidSourceURLWithMapError) Error ¶ added in v0.67.7
func (err InvalidSourceURLWithMapError) Error() string
type MaxIterError ¶ added in v0.19.14
type MaxIterError struct{}
func (MaxIterError) Error ¶ added in v0.19.14
func (err MaxIterError) Error() string
type MergeStrategyType ¶ added in v0.31.2
type MergeStrategyType string
const ( NoMerge MergeStrategyType = "no_merge" ShallowMerge MergeStrategyType = "shallow" DeepMerge MergeStrategyType = "deep" DeepMergeMapOnly MergeStrategyType = "deep_map_only" )
type ModuleDependencies ¶ added in v0.6.0
type ModuleDependencies struct {
Paths []string `hcl:"paths,attr" cty:"paths"`
}
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 MultipleBareIncludeBlocksErr ¶ added in v0.32.0
type MultipleBareIncludeBlocksErr struct{}
func (MultipleBareIncludeBlocksErr) Error ¶ added in v0.32.0
func (err MultipleBareIncludeBlocksErr) Error() string
type ParentFileNotFoundError ¶ added in v0.54.16
func (ParentFileNotFoundError) Error ¶ added in v0.54.16
func (err ParentFileNotFoundError) Error() string
type ParsedVariable ¶ added in v0.54.0
type ParsedVariable struct { Name string Description string Type string DefaultValue string DefaultValuePlaceholder string }
ParsedVariable structure with input name, default value and description.
func ParseVariables ¶ added in v0.54.0
func ParseVariables(opts *options.TerragruntOptions, directoryPath string) ([]*ParsedVariable, error)
ParseVariables - parse variables from tf files.
type ParsingContext ¶ added in v0.54.16
type ParsingContext struct { context.Context TerragruntOptions *options.TerragruntOptions // TrackInclude represents contexts of included configurations. TrackInclude *TrackInclude // Locals are pre-evaluated variable bindings that can be used by reference in the code. Locals *cty.Value // Features are the feature flags that are enabled for the current terragrunt config. Features *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 // PartialParseDecodeList is the list of sections that are being decoded in the current config. This can be used to // indicate/detect that the current parsing ctx is partial, meaning that not all configuration values are // expected to be available. PartialParseDecodeList []PartialDecodeSectionType // These functions have the highest priority and will overwrite any others with the same name PredefinedFunctions map[string]function.Function // `ParserOptions` is used to configure hcl Parser. ParserOptions []hclparse.Option // Set a custom converter to TerragruntConfig. // Used to read a "catalog" configuration where only certain blocks (`catalog`, `locals`) do not need to be converted, avoiding errors if any of the remaining blocks were not evaluated correctly. ConvertToTerragruntConfigFunc func(ctx *ParsingContext, configPath string, terragruntConfigFromFile *terragruntConfigFile) (cfg *TerragruntConfig, err error) }
ParsingContext provides various variables that are used throughout all funcs and passed from function to function. Using `ParsingContext` makes the code more readable.
func NewParsingContext ¶ added in v0.54.16
func NewParsingContext(ctx context.Context, opts *options.TerragruntOptions) *ParsingContext
func (ParsingContext) WithDecodeList ¶ added in v0.54.16
func (ctx ParsingContext) WithDecodeList(decodeList ...PartialDecodeSectionType) *ParsingContext
func (ParsingContext) WithFeatures ¶ added in v0.68.9
func (ctx ParsingContext) WithFeatures(features *cty.Value) *ParsingContext
WithFeatures sets the feature flags to be used in evaluation context.
func (ParsingContext) WithLocals ¶ added in v0.54.16
func (ctx ParsingContext) WithLocals(locals *cty.Value) *ParsingContext
func (ParsingContext) WithParseOption ¶ added in v0.61.0
func (ctx ParsingContext) WithParseOption(parserOptions []hclparse.Option) *ParsingContext
func (ParsingContext) WithTerragruntOptions ¶ added in v0.54.16
func (ctx ParsingContext) WithTerragruntOptions(opts *options.TerragruntOptions) *ParsingContext
func (ParsingContext) WithTrackInclude ¶ added in v0.54.16
func (ctx ParsingContext) WithTrackInclude(trackInclude *TrackInclude) *ParsingContext
type ParsingModulePathError ¶ added in v0.54.16
type ParsingModulePathError struct {
ModuleSourceURL string
}
func (ParsingModulePathError) Error ¶ added in v0.54.16
func (err ParsingModulePathError) 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 TerraformSource TerragruntFlags TerragruntInputs TerragruntVersionConstraints RemoteStateBlock FeatureFlagsBlock ExcludeBlock ErrorsBlock )
type RetryBlock ¶ added in v0.69.6
type RetryBlock struct { Label string `cty:"name" hcl:"name,label"` RetryableErrors []string `cty:"retryable_errors" hcl:"retryable_errors"` MaxAttempts int `cty:"max_attempts" hcl:"max_attempts"` SleepIntervalSec int `cty:"sleep_interval_sec" hcl:"sleep_interval_sec"` }
RetryBlock represents a labeled retry block
func (*RetryBlock) Clone ¶ added in v0.69.6
func (r *RetryBlock) Clone() *RetryBlock
Clone creates a deep copy of RetryBlock
type TFVarFileNotFoundError ¶ added in v0.52.5
func (TFVarFileNotFoundError) Error ¶ added in v0.52.5
func (err TFVarFileNotFoundError) Error() string
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"` ErrorHooks []ErrorHook `hcl:"error_hook,block"` // Ideally we can avoid the pointer to list slice, but if it is not a pointer, Terraform requires the attribute to // be defined and we want to make this optional. IncludeInCopy *[]string `hcl:"include_in_copy,attr"` CopyTerraformLockFile *bool `hcl:"copy_terraform_lock_file,attr"` }
TerraformConfig specifies where to find the Terraform configuration files NOTE: If any attributes or blocks are added here, be sure to add it to ctyTerraformConfig in config_as_cty.go as well.
func (*TerraformConfig) GetAfterHooks ¶ added in v0.14.4
func (cfg *TerraformConfig) GetAfterHooks() []Hook
func (*TerraformConfig) GetBeforeHooks ¶ added in v0.14.4
func (cfg *TerraformConfig) GetBeforeHooks() []Hook
func (*TerraformConfig) GetErrorHooks ¶ added in v0.35.20
func (cfg *TerraformConfig) GetErrorHooks() []ErrorHook
func (*TerraformConfig) String ¶ added in v0.9.4
func (cfg *TerraformConfig) String() string
func (*TerraformConfig) ValidateHooks ¶ added in v0.14.4
func (cfg *TerraformConfig) ValidateHooks() error
type TerraformExtraArguments ¶ added in v0.10.2
type TerraformExtraArguments struct { Name string `hcl:"name,label" cty:"name"` Arguments *[]string `hcl:"arguments,attr" cty:"arguments"` RequiredVarFiles *[]string `hcl:"required_var_files,attr" cty:"required_var_files"` OptionalVarFiles *[]string `hcl:"optional_var_files,attr" cty:"optional_var_files"` Commands []string `hcl:"commands,attr" cty:"commands"` EnvVars *map[string]string `hcl:"env_vars,attr" cty:"env_vars"` }
TerraformExtraArguments sets a list of arguments to pass to Terraform if command fits any in the `Commands` list
func (*TerraformExtraArguments) GetVarFiles ¶ added in v0.28.11
func (args *TerraformExtraArguments) GetVarFiles(logger log.Logger) []string
func (*TerraformExtraArguments) String ¶ added in v0.10.2
func (args *TerraformExtraArguments) String() string
type TerragruntConfig ¶
type TerragruntConfig struct { Catalog *CatalogConfig Terraform *TerraformConfig TerraformBinary string TerraformVersionConstraint string TerragruntVersionConstraint string RemoteState *remote.RemoteState Dependencies *ModuleDependencies DownloadDir string PreventDestroy *bool Skip *bool IamRole string IamAssumeRoleDuration *int64 IamAssumeRoleSessionName string IamWebIdentityToken string Inputs map[string]interface{} Locals map[string]interface{} TerragruntDependencies Dependencies GenerateConfigs map[string]codegen.GenerateConfig RetryableErrors []string RetryMaxAttempts *int RetrySleepIntervalSec *int Engine *EngineConfig FeatureFlags FeatureFlags Exclude *ExcludeConfig Errors *ErrorsConfig // Fields used for internal tracking // Indicates whether this is the result of a partial evaluation IsPartial bool // Map of processed includes ProcessedIncludes IncludeConfigsMap // Map to store fields metadata FieldsMetadata map[string]map[string]interface{} // List of dependent modules DependentModulesPath []*string }
TerragruntConfig represents a parsed and expanded configuration NOTE: if any attributes are added, make sure to update terragruntConfigAsCty in config_as_cty.go
func ParseConfig ¶ added in v0.54.16
func ParseConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
ParseConfig parses the Terragrunt config contained in the given hcl file 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. Note that this step is skipped if we already retrieved all the dependencies (which is the case when parsing included config files). This is determined by the dependencyOutputs input parameter. 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 mergeable except for `locals` blocks, which are only scoped to be available within the defining config.
func ParseConfigFile ¶ added in v0.6.0
func ParseConfigFile(ctx *ParsingContext, configPath string, includeFromChild *IncludeConfig) (*TerragruntConfig, 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 ParseConfigString ¶ added in v0.19.0
func ParseConfigString(ctx *ParsingContext, configPath string, configString string, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
func PartialParseConfig ¶ added in v0.54.16
func PartialParseConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
func PartialParseConfigFile ¶ added in v0.19.20
func PartialParseConfigFile(ctx *ParsingContext, configPath string, include *IncludeConfig) (*TerragruntConfig, error)
func PartialParseConfigString ¶ added in v0.19.20
func PartialParseConfigString(ctx *ParsingContext, configPath, configString string, include *IncludeConfig) (*TerragruntConfig, error)
PartialParseConfigString 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
- TerragruntVersionConstraints: Parses the attributes related to constraining terragrunt and terraform versions in the config.
- RemoteStateBlock: Parses the `remote_state` block in the config
- FeatureFlagsBlock: Parses the `feature` block in the config
- ExcludeBlock : Parses the `exclude` block 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(ctx context.Context, terragruntOptions *options.TerragruntOptions, parserOptions []hclparse.Option) (*TerragruntConfig, error)
ReadTerragruntConfig reads the Terragrunt config file from its default location
func TerragruntConfigFromPartialConfig ¶ added in v0.54.16
func TerragruntConfigFromPartialConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error)
TerragruntConfigFromPartialConfig is a wrapper of PartialParseConfigString which checks for cached configs. filename, configString, includeFromChild and decodeList are used for the cache key, by getting the default value (%#v) through fmt.
func (*TerragruntConfig) DeepMerge ¶ added in v0.31.4
func (cfg *TerragruntConfig) DeepMerge(sourceConfig *TerragruntConfig, terragruntOptions *options.TerragruntOptions) error
DeepMerge performs a deep merge of the given sourceConfig into the targetConfig. Deep merge is defined as follows:
- For simple types, the source overrides the target.
- For lists, the two attribute lists are combined together in concatenation.
- For maps, the two maps are combined together recursively. That is, if the map keys overlap, then a deep merge is performed on the map value.
- Note that some structs are not deep mergeable due to an implementation detail. This will change in the future. The following structs have this limitation:
- remote_state
- generate
- Note that the following attributes are deliberately omitted from the merge operation, as they are handled differently in the parser:
- dependency blocks (TerragruntDependencies) [These blocks need to retrieve outputs, so we need to merge during the parsing step, not after the full config is decoded]
- locals [These blocks are not merged by design]
func (*TerragruntConfig) EngineOptions ¶ added in v0.62.0
func (cfg *TerragruntConfig) EngineOptions() (*options.EngineOptions, error)
EngineOptions fetch engine options
func (*TerragruntConfig) ErrorsConfig ¶ added in v0.69.6
func (cfg *TerragruntConfig) ErrorsConfig() (*options.ErrorsConfig, error)
ErrorsConfig fetch errors configuration for options package
func (*TerragruntConfig) GetFieldMetadata ¶ added in v0.38.6
func (cfg *TerragruntConfig) GetFieldMetadata(fieldName string) (map[string]string, bool)
GetFieldMetadata return field metadata by field name.
func (*TerragruntConfig) GetIAMRoleOptions ¶ added in v0.35.1
func (cfg *TerragruntConfig) GetIAMRoleOptions() options.IAMRoleOptions
GetIAMRoleOptions is a helper function that converts the Terragrunt config IAM role attributes to options.IAMRoleOptions struct.
func (*TerragruntConfig) GetMapFieldMetadata ¶ added in v0.38.6
func (cfg *TerragruntConfig) GetMapFieldMetadata(fieldType, fieldName string) (map[string]string, bool)
GetMapFieldMetadata return field metadata by field type and name.
func (*TerragruntConfig) Merge ¶ added in v0.31.2
func (cfg *TerragruntConfig) Merge(sourceConfig *TerragruntConfig, terragruntOptions *options.TerragruntOptions) error
Merge performs a shallow merge of the given sourceConfig into the targetConfig. sourceConfig will override common attributes defined in the targetConfig. Note that this will modify the targetConfig. NOTE: the following attributes are deliberately omitted from the merge operation, as they are handled differently in the parser:
- locals [These blocks are not merged by design]
NOTE: dependencies block is a special case and is merged deeply. This is necessary to ensure the configstack system works correctly, as it uses the `Dependencies` list to track the dependencies of modules for graph building purposes. This list includes the dependencies added from dependency blocks, which is handled in a different stage.
func (*TerragruntConfig) SetFieldMetadata ¶ added in v0.38.6
func (cfg *TerragruntConfig) SetFieldMetadata(fieldName string, m map[string]interface{})
SetFieldMetadata set metadata on the given field name.
func (*TerragruntConfig) SetFieldMetadataMap ¶ added in v0.38.6
func (cfg *TerragruntConfig) SetFieldMetadataMap(field string, data map[string]interface{}, metadata map[string]interface{})
SetFieldMetadataMap set metadata on fields from map keys. Example usage - setting metadata on all variables from inputs.
func (*TerragruntConfig) SetFieldMetadataWithType ¶ added in v0.38.6
func (cfg *TerragruntConfig) SetFieldMetadataWithType(fieldType, fieldName string, m map[string]interface{})
SetFieldMetadataWithType set metadata on the given field name grouped by type. Example usage - setting metadata on different dependencies, locals, inputs.
func (*TerragruntConfig) String ¶ added in v0.9.4
func (cfg *TerragruntConfig) String() string
type TerragruntConfigNotFoundError ¶ added in v0.54.16
type TerragruntConfigNotFoundError struct {
Path string
}
func (TerragruntConfigNotFoundError) Error ¶ added in v0.54.16
func (err TerragruntConfigNotFoundError) Error() string
type TerragruntDependency ¶ added in v0.66.7
type TerragruntDependency struct { Dependencies Dependencies `hcl:"dependency,block"` Remain hcl.Body `hcl:",remain"` }
TerragruntDependency is a struct that can be used to only decode the dependency blocks in the terragrunt config
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 TooManyLevelsOfInheritanceError ¶ added in v0.54.16
type TooManyLevelsOfInheritanceError struct { ConfigPath string FirstLevelIncludePath string SecondLevelIncludePath string }
func (TooManyLevelsOfInheritanceError) Error ¶ added in v0.54.16
func (err TooManyLevelsOfInheritanceError) Error() string
type TrackInclude ¶ added in v0.30.4
type TrackInclude struct { // CurrentList is used to track the list of configs that should be imported and merged before the final // TerragruntConfig is returned. This preserves the order of the blocks as they appear in the config, so that we can // merge the included config in the right order. CurrentList IncludeConfigs // CurrentMap is the map version of CurrentList that maps the block labels to the included config. CurrentMap map[string]IncludeConfig // Original is used to track the original included config, and is used for resolving the include related // functions. Original *IncludeConfig }
TrackInclude is used to differentiate between an included config in the current parsing ctx, and an included config that was passed through from a previous parsing ctx.
type ValueWithMetadata ¶ added in v0.38.6
type ValueWithMetadata struct { Value cty.Value `json:"value" cty:"value"` Metadata map[string]string `json:"metadata" cty:"metadata"` }
ValueWithMetadata stores value and metadata used in render-json with metadata.
type WrongNumberOfParamsError ¶ added in v0.54.16
func (WrongNumberOfParamsError) Error ¶ added in v0.54.16
func (err WrongNumberOfParamsError) Error() string