options

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 10 Imported by: 77

Documentation

Index

Constants

View Source
const DEFAULT_IAM_ASSUME_ROLE_DURATION = 3600
View Source
const DEFAULT_LOG_LEVEL = util.DEFAULT_LOG_LEVEL

DEFAULT_LOG_LEVEL defines default log level for Terragrunt

View Source
const DEFAULT_MAX_FOLDERS_TO_CHECK = 100
View Source
const DEFAULT_PARALLELISM = math.MaxInt32

no limits on parallelism by default (limited by GOPROCS)

View Source
const DEFAULT_RETRY_MAX_ATTEMPTS = 3
View Source
const DEFAULT_RETRY_SLEEP_INTERVAL_SEC = 5 * time.Second
View Source
const DefaultTFDataDir = ".terraform"
View Source
const TERRAFORM_DEFAULT_PATH = "terraform"

TERRAFORM_DEFAULT_PATH just takes terraform from the path

View Source
const TerragruntCacheDir = ".terragrunt-cache"

Variables

View Source
var DEFAULT_RETRYABLE_ERRORS = []string{
	"(?s).*Failed to load state.*tcp.*timeout.*",
	"(?s).*Failed to load backend.*TLS handshake timeout.*",
	"(?s).*Creating metric alarm failed.*request to update this alarm is in progress.*",
	"(?s).*Error installing provider.*TLS handshake timeout.*",
	"(?s).*Error configuring the backend.*TLS handshake timeout.*",
	"(?s).*Error installing provider.*tcp.*timeout.*",
	"(?s).*Error installing provider.*tcp.*connection reset by peer.*",
	"NoSuchBucket: The specified bucket does not exist",
	"(?s).*Error creating SSM parameter: TooManyUpdates:.*",
	"(?s).*app.terraform.io.*: 429 Too Many Requests.*",
	"(?s).*ssh_exchange_identification.*Connection closed by remote host.*",
}

List of recurring transient errors encountered when calling terraform If any of these match, we'll retry the command

View Source
var RunTerragruntCommandNotSet = fmt.Errorf("The RunTerragrunt option has not been set on this TerragruntOptions object")
View Source
var TERRAFORM_COMMANDS_WITH_SUBCOMMAND = []string{
	"debug",
	"force-unlock",
	"state",
}

Functions

func DefaultWorkingAndDownloadDirs added in v0.16.2

func DefaultWorkingAndDownloadDirs(terragruntConfigPath string) (string, string, error)

Get the default working and download directories for the given Terragrunt config path

Types

type TerragruntOptions

type TerragruntOptions struct {
	// Location of the Terragrunt config file
	TerragruntConfigPath string

	// Location of the original Terragrunt config file. This is primarily useful when one Terragrunt config is being
	// read from another: e.g., if /terraform-code/terragrunt.hcl calls read_terragrunt_config("/foo/bar.hcl"),
	// and within bar.hcl, you call get_original_terragrunt_dir(), you'll get back /terraform-code.
	OriginalTerragruntConfigPath string

	// Version of terragrunt
	TerragruntVersion *version.Version

	// Location of the terraform binary
	TerraformPath string

	// Current Terraform command being executed by Terragrunt
	TerraformCommand string

	// Original Terraform command being executed by Terragrunt. Used to track command evolution as terragrunt chains
	// different commands together. For example, when retrieving dependencies, terragrunt will change the
	// TerraformCommand to `output` to run `terraform output`, which loses the context of the original command that was
	// run to fetch the dependency. This is a problem when mock_outputs is configured and we only allow mocks to be
	// returned on specific commands.
	// NOTE: For `xxx-all` commands, this will be set to the Terraform command, which would be `xxx`. For example,
	// if you run `apply-all` (which is a terragrunt command), this variable will be set to `apply`.
	OriginalTerraformCommand string

	// Version of terraform (obtained by running 'terraform version')
	TerraformVersion *version.Version

	// Whether we should prompt the user for confirmation or always assume "yes"
	NonInteractive bool

	// Whether we should automatically run terraform init if necessary when executing other commands
	AutoInit bool

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

	// Basic log entry
	Logger *logrus.Entry

	// Log level
	LogLevel logrus.Level

	// Environment variables at runtime
	Env map[string]string

	// Download Terraform configurations from the specified source location into a temporary folder and run
	// Terraform in that temporary folder
	Source string

	// Map to replace terraform source locations. This will replace occurences of the given source with the target
	// value.
	SourceMap map[string]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

	// The ARN of an IAM Role to assume before running Terraform
	IamRole string

	// Duration of the STS Session
	IamAssumeRoleDuration int64

	// 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, ignore the dependency order when running *-all command.
	IgnoreDependencyOrder bool

	// If set to true, skip any external dependencies when running *-all commands
	IgnoreExternalDependencies bool

	// If set to true, apply all external dependencies when running *-all commands
	IncludeExternalDependencies bool

	// If you want stdout to go somewhere other than os.stdout
	Writer io.Writer

	// If you want stderr to go somewhere other than os.stderr
	ErrWriter io.Writer

	// When searching the directory tree, this is the max folders to check before exiting with an error. This is
	// exposed here primarily so we can set it to a low value at test time.
	MaxFoldersToCheck int

	// Whether we should automatically retry errored Terraform commands
	AutoRetry bool

	// Maximum number of times to retry errors matching RetryableErrors
	RetryMaxAttempts int

	// The duration in seconds to wait before retrying
	RetrySleepIntervalSec time.Duration

	// RetryableErrors is an array of regular expressions with RE2 syntax (https://github.com/google/re2/wiki/Syntax) that qualify for retrying
	RetryableErrors []string

	// Unix-style glob of directories to exclude when running *-all commands
	ExcludeDirs []string

	// Unix-style glob of directories to include when running *-all commands
	IncludeDirs []string

	// If set to true, do not include dependencies when processing IncludeDirs (unless they are in the included dirs)
	StrictInclude bool

	// Parallelism limits the number of commands to run concurrently during *-all commands
	Parallelism int

	// Enable check mode, by default it's disabled.
	Check bool

	// The file which hclfmt should be specifically run on
	HclFile string

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

	// True if terragrunt should run in debug mode, writing terragrunt-debug.tfvars to working folder to help
	// root-cause issues.
	Debug bool

	// Attributes to override in AWS provider nested within modules as part of the aws-provider-patch command. See that
	// command for more info.
	AwsProviderPatchOverrides map[string]string
}

TerragruntOptions represents options that configure the behavior of the Terragrunt program

func NewTerragruntOptions added in v0.6.0

func NewTerragruntOptions(terragruntConfigPath string) (*TerragruntOptions, error)

Create a new TerragruntOptions object with reasonable defaults for real usage

func NewTerragruntOptionsForTest added in v0.6.0

func NewTerragruntOptionsForTest(terragruntConfigPath string) (*TerragruntOptions, error)

Create a new TerragruntOptions object with reasonable defaults for test usage

func (*TerragruntOptions) AppendTerraformCliArgs added in v0.13.0

func (terragruntOptions *TerragruntOptions) AppendTerraformCliArgs(argsToAppend ...string)

Appends the given argsToAppend after the current TerraformCliArgs

func (*TerragruntOptions) Clone added in v0.6.0

func (terragruntOptions *TerragruntOptions) Clone(terragruntConfigPath string) *TerragruntOptions

Create 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) DataDir added in v0.20.1

func (terragruntOptions *TerragruntOptions) DataDir() string

DataDir returns the Terraform data directory prepended with the working directory path, or just the Terraform data directory if it is an absolute path.

func (*TerragruntOptions) InsertTerraformCliArgs added in v0.13.0

func (terragruntOptions *TerragruntOptions) InsertTerraformCliArgs(argsToInsert ...string)

Inserts the given argsToInsert after the terraform command argument, but before the remaining args

func (*TerragruntOptions) TerraformDataDir added in v0.23.24

func (terragruntOptions *TerragruntOptions) TerraformDataDir() string

TerraformDataDir returns Terraform data directory (.terraform by default, overridden by $TF_DATA_DIR envvar)

Jump to

Keyboard shortcuts

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