Documentation ¶
Index ¶
- Constants
- Variables
- type SetVariableResult
- type TerragruntOptions
- func (terragruntOptions TerragruntOptions) Clone(terragruntConfigPath string) *TerragruntOptions
- func (terragruntOptions *TerragruntOptions) CloseWriters()
- func (terragruntOptions *TerragruntOptions) ConfigPath(folder string) (string, bool)
- func (terragruntOptions *TerragruntOptions) EnvironmentVariables() (result []string)
- func (terragruntOptions *TerragruntOptions) FindConfigFilesInPath(rootPath string) ([]string, error)
- func (terragruntOptions TerragruntOptions) GetContext() (result collections.IDictionary)
- func (terragruntOptions *TerragruntOptions) GetVariableValue(key string) (value interface{}, found bool)
- func (terragruntOptions *TerragruntOptions) ImportVariablesMap(vars map[string]interface{}, origin VariableSource) (result []hcl.Dictionary)
- func (terragruntOptions *TerragruntOptions) LoadVariablesFromFile(path string) (map[string]interface{}, error)
- func (terragruntOptions *TerragruntOptions) LoadVariablesFromTemplateFile(path string, template bool) (map[string]interface{}, error)
- func (terragruntOptions *TerragruntOptions) Printf(format string, args ...interface{}) (n int, err error)
- func (terragruntOptions *TerragruntOptions) Println(args ...interface{}) (n int, err error)
- func (terragruntOptions *TerragruntOptions) SetStatus(exitCode int, err error)
- func (terragruntOptions *TerragruntOptions) SetVariable(key string, value interface{}, source VariableSource) SetVariableResult
- func (terragruntOptions *TerragruntOptions) VariablesExplicitlyProvided() (result []string)
- type Variable
- type VariableSource
Constants ¶
const ( IgnoreFile = "terragrunt.ignore" IgnoreFileNonInteractive = "terragrunt-non-interactive.ignore" DefaultConfigName = "terragrunt.hcl" )
Global constants
const ( EnvCacheFolder = "TERRAGRUNT_CACHE_FOLDER" // Used to configure the cache folder (optional, default determined by os temp folder) EnvConfig = "TERRAGRUNT_CONFIG" // Used to configure the location of the Terragrunt configuration file (optional, default terragrunt.hcl in the current folder) EnvDebug = "TERRAGRUNT_DEBUG" // Used to enable Terragrunt debug mode EnvFlushDelay = "TERRAGRUNT_FLUSH_DELAY" // Used to configure the flush delay on long -all operation (default 60s) EnvLoggingLevel = "TERRAGRUNT_LOGGING_LEVEL" // Used to configure the current logging level EnvLoggingFileDir = "TERRAGRUNT_LOGGING_FILE_DIR" // Used to configure the directory where (verbose) file logs will be saved EnvLoggingFileLevel = "TERRAGRUNT_LOGGING_FILE_LEVEL" // Used to configure the logging level in files EnvSource = "TERRAGRUNT_SOURCE" // Used to configure the location of the Terraform source folder (optional, default determined by source in the terragrunt.terraform object EnvSourceUpdate = "TERRAGRUNT_SOURCE_UPDATE" // Used to configure the --terragrunt-source-update option (flushes the cache) (optional) EnvTFPath = "TERRAGRUNT_TFPATH" // Used to configure the path to the terraform command (optional, default terraform) EnvWorkers = "TERRAGRUNT_WORKERS" // Used to configure the maximum number of concurrent workers (optional) EnvApplyTemplate = "TERRAGRUNT_TEMPLATE" // Used to configure whether or not go template should be applied on terraform (.tf and .tfvars) file EnvTemplatePatterns = "TERRAGRUNT_TEMPLATE_PATTERNS" // Used to configure the extra files (other than .tf) that should be processed by go template EnvBootConfigs = "TERRAGRUNT_BOOT_CONFIGS" // Used to set defaults configuration when launching terragrunt EnvPreBootConfigs = "TERRAGRUNT_PREBOOT_CONFIGS" // Used to set defaults configuration when launching terragrunt (loaded before user files) EnvIncludeEmptyFolders = "TERRAGRUNT_INCLUDE_EMPTY_FOLDERS" // Used to set the option terragrunt-include-empty-folders EnvAssumedRoleID = "TERRAGRUNT_ASSUMED_ROLE_ID" // Used to configure the name of the role assumed by terragrunt EnvPluginsDirectory = "TERRAGRUNT_PLUGINS_DIRECTORY" // Used to restrict the plugins download directory )
All environment variables that could be used to configure Terragrunt
const ( EnvArgs = "TERRAGRUNT_ARGS" // Used to publish the supplied arguments to the Terragrunt command EnvCommand = "TERRAGRUNT_COMMAND" // Used to publish the current Terragrunt command EnvExtraCommand = "TERRAGRUNT_EXTRA_COMMAND" // Used to publish the name of the actual running command EnvLaunchFolder = "TERRAGRUNT_LAUNCH_FOLDER" // Used to publish the launch folder from where the Terragrunt operation has been launched EnvRunID = "TERRAGRUNT_RUN_ID" // Used to publish the current run id, this is unique to each Terragrunt execution, but can be used to link -all operations EnvSourceFolder = "TERRAGRUNT_SOURCE_FOLDER" // Used to publish the current Terraform source folder used EnvTemporaryFolder = "TERRAGRUNT_TEMPORARY_FOLDER" // Used to publish the Terragrunt temporary folder used EnvTFVersion = "TERRAFORM_VERSION" // Used to publish the Terraform version EnvVersion = "TERRAGRUNT_VERSION" // Used to publish the Terragrunt version )
All environment variables that are published during Terragrunt execution to share current context during shell execution
const ( EnvLastError = "TERRAGRUNT_LAST_ERROR" // Used to publish the last executed command error message EnvLastStatus = "TERRAGRUNT_LAST_STATUS" // Used to publish the last executed command exit code EnvError = "TERRAGRUNT_ERROR" // Used to publish the cumulated command error if there are EnvStatus = "TERRAGRUNT_STATUS" // Used to publish the status of the execution flow )
All environment variables that are published during Terragrunt execution to indicate the current execution status
Variables ¶
var ( // TerraformFilesPatterns lists the patterns of expected files considered as terraform content. TerraformFilesPatterns = []string{"*.tf", "*.tf.json"} // TerraformFilesPatternsExtended lists the patterns of expected files considered as terraform content (including other file format). TerraformFilesPatternsExtended = append(TerraformFilesPatterns, "*.tf.yaml") // TerraformFilesTemplates list all files that may contains terraform code (while expanded). TerraformFilesTemplates []string )
var ErrRunTerragruntCommandNotSet = fmt.Errorf("the RunTerragrunt option has not been set on this TerragruntOptions object")
ErrRunTerragruntCommandNotSet is a custom error
Functions ¶
This section is empty.
Types ¶
type SetVariableResult ¶
type SetVariableResult byte
SetVariableResult indicates the status of trying to add a variable to the options
const ( IgnoredVariable SetVariableResult = iota NewVariable Overwritten SetVariableResultCount )
Valid values for SetVariableResult
func (SetVariableResult) String ¶
func (i SetVariableResult) String() string
type TerragruntOptions ¶
type TerragruntOptions struct { // Location of the Terragrunt config file TerragruntConfigPath string // Location of the terraform binary TerraformPath string // Whether we should prompt the user for confirmation or always assume "yes" NonInteractive bool // The approval handler that will be used in a non interactive context ApprovalHandler string // CLI args that are intended for Terraform (i.e. all the CLI args except the --terragrunt ones) TerraformCliArgs []string // The working directory in which to run Terraform WorkingDir string // The AWS profile to use if specified (default = "") AwsProfile string // The logger to use for all logging Logger *multilogger.Logger // Environment variables at runtime Env map[string]string // Terraform variables at runtime Variables map[string]Variable // The current execution context Context map[string]interface{} // Download Terraform configurations from the specified source location into a temporary folder and run // Terraform in that temporary folder Source string // If set to true, delete the contents of the temporary folder before downloading Terraform source code into it SourceUpdate bool // Download Terraform configurations specified in the Source parameter into this folder DownloadDir string // If set to true, continue running *-all commands even if a dependency has errors. This is mostly useful for 'output-all <some_variable>'. See https://github.com/gruntwork-io/terragrunt/issues/193 IgnoreDependencyErrors bool // If set to true, check if the source folder contains terraform files to determine if the folder should be excluded from the stack CheckSourceFolders bool // If you want stdout to go somewhere other than os.stdout Writer io.WriteCloser // If you want stderr to go somewhere other than os.stderr ErrWriter io.WriteCloser // A command that can be used to run Terragrunt with the given options. This is useful for running Terragrunt // multiple times (e.g. when spinning up a stack of Terraform modules). The actual command is normally defined // in the cli package, which depends on almost all other packages, so we declare it here so that other // packages can use the command without a direct reference back to the cli package (which would create a // circular dependency). RunTerragrunt func(*TerragruntOptions) error // If set in terragrunt configuration, this string is added to the directory name before calculating the hashing // This allow differentiation based on certain attribute to ensure that different config (env, region) are executed // in distinct folder UniquenessCriteria string // Indicates the maximum wait time before flushing the output of a background job RefreshOutputDelay time.Duration // Indicates the number of concurrent workers NbWorkers int // ApplyTemplate configures whether or not go template should be applied on terraform (.tf and .tfvars) file ApplyTemplate bool // TemplateAdditionalPatterns configures additional paths where templating should be applied. Does nothing if ApplyTemplate is false TemplateAdditionalPatterns []string // BootConfigurationPaths is used to set defaults configuration when launching terragrunt. These will be loaded after the user's config BootConfigurationPaths []string // PreBootConfigurationPaths is used to set defaults configuration when launching terragrunt. These will be loaded before the user's config PreBootConfigurationPaths []string // PluginsDirectory is used to restrict plugin downloads to a specific directory (no remote plugins will be downloaded if this is set) PluginsDirectory string }
TerragruntOptions represents options that configure the behavior of the Terragrunt program
func NewTerragruntOptions ¶
func NewTerragruntOptions(terragruntConfigPath string) *TerragruntOptions
NewTerragruntOptions creates a new TerragruntOptions object with reasonable defaults for real usage
func NewTerragruntOptionsForTest ¶
func NewTerragruntOptionsForTest(terragruntConfigPath string) *TerragruntOptions
NewTerragruntOptionsForTest creates a new TerragruntOptions object with reasonable defaults for test usage
func (TerragruntOptions) Clone ¶
func (terragruntOptions TerragruntOptions) Clone(terragruntConfigPath string) *TerragruntOptions
Clone creates a copy of this TerragruntOptions, but with different values for the given variables. This is useful for creating a TerragruntOptions that behaves the same way, but is used for a Terraform module in a different folder.
func (*TerragruntOptions) CloseWriters ¶
func (terragruntOptions *TerragruntOptions) CloseWriters()
CloseWriters indicates to the writers that it can be closed
func (*TerragruntOptions) ConfigPath ¶
func (terragruntOptions *TerragruntOptions) ConfigPath(folder string) (string, bool)
ConfigPath builds a path to the config file into the provided folder.
func (*TerragruntOptions) EnvironmentVariables ¶
func (terragruntOptions *TerragruntOptions) EnvironmentVariables() (result []string)
EnvironmentVariables returns an array of string that defines the environment variables as required by external commands
func (*TerragruntOptions) FindConfigFilesInPath ¶
func (terragruntOptions *TerragruntOptions) FindConfigFilesInPath(rootPath string) ([]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 its name matches the DefaultConfigName constant and contains Terragrunt config contents as returned by the IsTerragruntConfig method.
func (TerragruntOptions) GetContext ¶
func (terragruntOptions TerragruntOptions) GetContext() (result collections.IDictionary)
GetContext returns the current context from the variables set
func (*TerragruntOptions) GetVariableValue ¶
func (terragruntOptions *TerragruntOptions) GetVariableValue(key string) (value interface{}, found bool)
GetVariableValue returns the value of a variable with the given key. Supports dot notation (my_map.my_var)
func (*TerragruntOptions) ImportVariablesMap ¶
func (terragruntOptions *TerragruntOptions) ImportVariablesMap(vars map[string]interface{}, origin VariableSource) (result []hcl.Dictionary)
ImportVariablesMap adds the supplied variables to the TerragruntOptions object
func (*TerragruntOptions) LoadVariablesFromFile ¶
func (terragruntOptions *TerragruntOptions) LoadVariablesFromFile(path string) (map[string]interface{}, error)
LoadVariablesFromFile loads variables from the file indicated by path
func (*TerragruntOptions) LoadVariablesFromTemplateFile ¶
func (terragruntOptions *TerragruntOptions) LoadVariablesFromTemplateFile(path string, template bool) (map[string]interface{}, error)
LoadVariablesFromTemplateFile loads variables from the template file indicated by path. If template is set to true, templating will be be applied on the file before reading it
func (*TerragruntOptions) Printf ¶
func (terragruntOptions *TerragruntOptions) Printf(format string, args ...interface{}) (n int, err error)
Printf uses the embedded writer to print
func (*TerragruntOptions) Println ¶
func (terragruntOptions *TerragruntOptions) Println(args ...interface{}) (n int, err error)
Println uses the embedded writer to print
func (*TerragruntOptions) SetStatus ¶
func (terragruntOptions *TerragruntOptions) SetStatus(exitCode int, err error)
SetStatus saves environment variables indicating the current execution status
func (*TerragruntOptions) SetVariable ¶
func (terragruntOptions *TerragruntOptions) SetVariable(key string, value interface{}, source VariableSource) SetVariableResult
SetVariable overwrites the value in the variables map only if the source is more significant than the original value
func (*TerragruntOptions) VariablesExplicitlyProvided ¶
func (terragruntOptions *TerragruntOptions) VariablesExplicitlyProvided() (result []string)
VariablesExplicitlyProvided returns the list of variables that have been explicitly provided as argument
type Variable ¶
type Variable struct { Source VariableSource Value interface{} }
Variable defines value and origin of a variable (origin is important due to the precedence of the definition) i.e. A value specified by -var has precedence over value defined in -var-file
type VariableSource ¶
type VariableSource byte
VariableSource is an enum defining the priority of the source for variable definition
const ( UndefinedSource VariableSource = iota Default ConfigVarFile VarFile VarFileExplicit VarParameter Environment VarParameterExplicit FunctionOverwrite )
The order indicates precedence (latest have the highest priority)
func (VariableSource) String ¶
func (i VariableSource) String() string