cli

package
v0.27.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const CMD_APPLY_ALL = "apply-all"
View Source
const CMD_AWS_PROVIDER_PATCH = "aws-provider-patch"
View Source
const CMD_DESTROY_ALL = "destroy-all"
View Source
const CMD_HCLFMT = "hclfmt"
View Source
const CMD_INIT = "init"
View Source
const CMD_INIT_FROM_MODULE = "init-from-module"
View Source
const CMD_LOCK = "lock"
View Source
const CMD_OUTPUT_ALL = "output-all"
View Source
const CMD_PLAN_ALL = "plan-all"
View Source
const CMD_PROVIDERS = "providers"
View Source
const CMD_SPIN_UP = "spin-up"

CMD_SPIN_UP is deprecated.

View Source
const CMD_TEAR_DOWN = "tear-down"

CMD_TEAR_DOWN is deprecated.

View Source
const CMD_TERRAGRUNT_GRAPH_DEPENDENCIES = "graph-dependencies"
View Source
const CMD_TERRAGRUNT_INFO = "terragrunt-info"
View Source
const CMD_TERRAGRUNT_READ_CONFIG = "terragrunt-read-config"
View Source
const CMD_VALIDATE_ALL = "validate-all"
View Source
const DEFAULT_TERRAFORM_VERSION_CONSTRAINT = ">= v0.12.0"

This uses the constraint syntax from https://github.com/hashicorp/go-version This version of Terragrunt was tested to work with Terraform 0.12.0 and above only

View Source
const MODULE_MANIFEST_NAME = ".terragrunt-module-manifest"

manifest for files coped from terragrunt module folder (i.e., the folder that contains the current terragrunt.hcl)

View Source
const OPT_DOWNLOAD_DIR = "terragrunt-download-dir"
View Source
const OPT_NON_INTERACTIVE = "terragrunt-non-interactive"
View Source
const OPT_TERRAGRUNT_CHECK = "terragrunt-check"
View Source
const OPT_TERRAGRUNT_CONFIG = "terragrunt-config"
View Source
const OPT_TERRAGRUNT_DEBUG = "terragrunt-debug"
View Source
const OPT_TERRAGRUNT_EXCLUDE_DIR = "terragrunt-exclude-dir"
View Source
const OPT_TERRAGRUNT_HCLFMT_FILE = "terragrunt-hclfmt-file"
View Source
const OPT_TERRAGRUNT_IAM_ROLE = "terragrunt-iam-role"
View Source
const OPT_TERRAGRUNT_IGNORE_DEPENDENCY_ERRORS = "terragrunt-ignore-dependency-errors"
View Source
const OPT_TERRAGRUNT_IGNORE_DEPENDENCY_ORDER = "terragrunt-ignore-dependency-order"
View Source
const OPT_TERRAGRUNT_IGNORE_EXTERNAL_DEPENDENCIES = "terragrunt-ignore-external-dependencies"
View Source
const OPT_TERRAGRUNT_INCLUDE_DIR = "terragrunt-include-dir"
View Source
const OPT_TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES = "terragrunt-include-external-dependencies"
View Source
const OPT_TERRAGRUNT_NO_AUTO_INIT = "terragrunt-no-auto-init"
View Source
const OPT_TERRAGRUNT_NO_AUTO_RETRY = "terragrunt-no-auto-retry"
View Source
const OPT_TERRAGRUNT_OVERRIDE_ATTR = "terragrunt-override-attr"
View Source
const OPT_TERRAGRUNT_PARALLELISM = "terragrunt-parallelism"
View Source
const OPT_TERRAGRUNT_SOURCE = "terragrunt-source"
View Source
const OPT_TERRAGRUNT_SOURCE_UPDATE = "terragrunt-source-update"
View Source
const OPT_TERRAGRUNT_STRICT_INCLUDE = "terragrunt-strict-include"
View Source
const OPT_TERRAGRUNT_TFPATH = "terragrunt-tfpath"
View Source
const OPT_WORKING_DIR = "terragrunt-working-dir"
View Source
const SOURCE_MANIFEST_NAME = ".terragrunt-source-manifest"

manifest for files copied from the URL specified in the terraform { source = "<URL>" } config

View Source
const TERRAFORM_EXTENSION_GLOB = "*.tf"
View Source
const TerragruntTFVarsFile = "terragrunt-debug.tfvars.json"

Variables

View Source
var CUSTOM_USAGE_TEXT = `` /* 3779-byte string literal not displayed */

Since Terragrunt is just a thin wrapper for Terraform, and we don't want to repeat every single Terraform command in its definition, we don't quite fit into the model of any Go CLI library. Fortunately, urfave/cli allows us to override the whole template used for the Usage Text.

TODO: this description text has copy/pasted versions of many Terragrunt constants, such as command names and file names. It would be easy to make this code DRY using fmt.Sprintf(), but then it's hard to make the text align nicely. Write some code to take generate this help text automatically, possibly leveraging code that's part of urfave/cli.

DEPRECATED_COMMANDS is a map of deprecated commands to the commands that replace them.

View Source
var MODULE_REGEX = regexp.MustCompile(`module[[:blank:]]+".+"`)
View Source
var TERRAFORM_COMMANDS_THAT_DO_NOT_NEED_INIT = []string{
	"version",
	"terragrunt-info",
	"graph-dependencies",
}
View Source
var TERRAFORM_COMMANDS_THAT_USE_STATE = []string{
	"init",
	"apply",
	"destroy",
	"env",
	"import",
	"graph",
	"output",
	"plan",
	"push",
	"refresh",
	"show",
	"taint",
	"untaint",
	"validate",
	"force-unlock",
	"state",
}
View Source
var TERRAFORM_HELP_FLAGS = []string{
	"--help",
	"-help",
	"-h",
}

The supported flags to show help of terraform commands

View Source
var TerraformVersionRegex = regexp.MustCompile(`Terraform (v?\d+\.\d+\.\d+).*`)

TerraformVersionRegex verifies that terraform --version output is in one of the following formats: - Terraform v0.9.5-dev (cad024a5fe131a546936674ef85445215bbc4226+CHANGES) - Terraform v0.13.0-beta2 - Terraform v0.12.27 We only make sure the "v#.#.#" part is present in the output.

Functions

func CheckTerraformVersion added in v0.12.5

func CheckTerraformVersion(constraint string, terragruntOptions *options.TerragruntOptions) error

Check that the currently installed Terraform version works meets the specified version constraint and return an error if it doesn't

func CheckTerragruntVersion added in v0.27.4

func CheckTerragruntVersion(constraint string, terragruntOptions *options.TerragruntOptions) error

Check that the currently running Terragrunt version meets the specified version constraint and return an error if it doesn't

func CreateTerragruntCli

func CreateTerragruntCli(version string, writer io.Writer, errwriter io.Writer) *cli.App

Create the Terragrunt CLI App

func ParseTerragruntOptions added in v0.6.0

func ParseTerragruntOptions(cliContext *cli.Context) (*options.TerragruntOptions, error)

Parse command line options that are passed in for Terragrunt

func PopulateTerraformVersion added in v0.13.0

func PopulateTerraformVersion(terragruntOptions *options.TerragruntOptions) error

Populate the currently installed version of Terraform into the given terragruntOptions

func RunTerragrunt added in v0.21.7

func RunTerragrunt(terragruntOptions *options.TerragruntOptions) error

Downloads terraform source if necessary, then runs terraform with the given options and CLI args. This will forward all the args and extra_arguments directly to Terraform.

Types

type ArgMissingValue added in v0.6.0

type ArgMissingValue string

func (ArgMissingValue) Error added in v0.6.0

func (err ArgMissingValue) Error() string

type ArgumentNotAllowed added in v0.13.0

type ArgumentNotAllowed struct {
	Argument string
	Message  string
}

func (ArgumentNotAllowed) Error added in v0.13.0

func (err ArgumentNotAllowed) Error() string

type BackendNotDefined added in v0.13.5

type BackendNotDefined struct {
	Opts        *options.TerragruntOptions
	BackendType string
}

func (BackendNotDefined) Error added in v0.13.5

func (err BackendNotDefined) Error() string

type FileCopyGetter added in v0.19.1

type FileCopyGetter struct {
	getter.FileGetter
}

A custom getter.Getter implementation that uses file copying instead of symlinks. Symlinks are faster and use less disk space, but they cause issues in Windows and with infinite loops, so we copy files/folders instead.

func (*FileCopyGetter) Get added in v0.19.1

func (g *FileCopyGetter) Get(dst string, u *url.URL) error

The original FileGetter does NOT know how to do folder copying (it only does symlinks), so we provide a copy implementation here

func (*FileCopyGetter) GetFile added in v0.19.1

func (g *FileCopyGetter) GetFile(dst string, u *url.URL) error

The original FileGetter already knows how to do file copying so long as we set the Copy flag to true, so just delegate to it

type InitNeededButDisabled added in v0.13.0

type InitNeededButDisabled string

func (InitNeededButDisabled) Error added in v0.13.0

func (err InitNeededButDisabled) Error() string

type InvalidKeyValue added in v0.27.4

type InvalidKeyValue string

func (InvalidKeyValue) Error added in v0.27.4

func (err InvalidKeyValue) Error() string

type InvalidTerraformVersion added in v0.12.5

type InvalidTerraformVersion struct {
	CurrentVersion     *version.Version
	VersionConstraints version.Constraints
}

func (InvalidTerraformVersion) Error added in v0.12.5

func (err InvalidTerraformVersion) Error() string

type InvalidTerraformVersionSyntax added in v0.12.5

type InvalidTerraformVersionSyntax string

func (InvalidTerraformVersionSyntax) Error added in v0.12.5

type InvalidTerragruntVersion added in v0.27.4

type InvalidTerragruntVersion struct {
	CurrentVersion     *version.Version
	VersionConstraints version.Constraints
}

func (InvalidTerragruntVersion) Error added in v0.27.4

func (err InvalidTerragruntVersion) Error() string

type MaxRetriesExceeded added in v0.17.0

type MaxRetriesExceeded struct {
	Opts *options.TerragruntOptions
}

func (MaxRetriesExceeded) Error added in v0.17.0

func (err MaxRetriesExceeded) Error() string

type MissingOverrides added in v0.27.4

type MissingOverrides string

func (MissingOverrides) Error added in v0.27.4

func (err MissingOverrides) Error() string

type ModuleIsProtected added in v0.16.4

type ModuleIsProtected struct {
	Opts *options.TerragruntOptions
}

func (ModuleIsProtected) Error added in v0.16.4

func (err ModuleIsProtected) Error() string

type NoTerraformFilesFound added in v0.16.0

type NoTerraformFilesFound string

func (NoTerraformFilesFound) Error added in v0.16.0

func (path NoTerraformFilesFound) Error() string

type TerraformModule added in v0.27.4

type TerraformModule struct {
	Key    string
	Source string
	Dir    string
}

type TerraformModulesJson added in v0.27.4

type TerraformModulesJson struct {
	Modules []TerraformModule
}

The format we expect in the .terraform/modules/modules.json file

type TerraformSource added in v0.9.7

type TerraformSource struct {
	// A canonical version of RawSource, in URL format
	CanonicalSourceURL *url.URL

	// The folder where we should download the source to
	DownloadDir string

	// The folder in DownloadDir that should be used as the working directory for Terraform
	WorkingDir string

	// The path to a file in DownloadDir that stores the version number of the code
	VersionFile string
}

This struct represents information about Terraform source code that needs to be downloaded

func ProcessTerraformSource added in v0.27.4

func ProcessTerraformSource(source string, downloadDir string, workingDir string, logger *log.Logger) (*TerraformSource, error)

Take the given source path and create a TerraformSource struct from it, including the folder where the source should be downloaded to. Our goal is to reuse the download folder for the same source URL between Terragrunt runs. Otherwise, for every Terragrunt command, you'd have to wait for Terragrunt to download your Terraform code, download that code's dependencies (terraform get), and configure remote state (terraform remote config), which is very slow.

To maximize reuse, given a working directory w and a source URL s, we download code from S into the folder /T/W/H where:

  1. S is the part of s before the double-slash (//). This typically represents the root of the repo (e.g. github.com/foo/infrastructure-modules). We download the entire repo so that relative paths to other files in that repo resolve correctly. If no double-slash is specified, all of s is used.
  2. T is the OS temp dir (e.g. /tmp).
  3. W is the base 64 encoded sha1 hash of w. This ensures that if you are running Terragrunt concurrently in multiple folders (e.g. during automated tests), then even if those folders are using the same source URL s, they do not overwrite each other.
  4. H is the base 64 encoded sha1 of S without its query string. For remote source URLs (e.g. Git URLs), this is based on the assumption that the scheme/host/path of the URL (e.g. git::github.com/foo/bar) identifies the repo, and we always want to download the same repo into the same folder (see the encodeSourceName method). We also assume the version of the module is stored in the query string (e.g. ref=v0.0.3), so we store the base 64 encoded sha1 of the query string in a file called .terragrunt-source-version within /T/W/H.

The downloadTerraformSourceIfNecessary decides when we should download the Terraform code and when not to. It uses the following rules:

  1. Always download source URLs pointing to local file paths.
  2. Only download source URLs pointing to remote paths if /T/W/H doesn't already exist or, if it does exist, if the version number in /T/W/H/.terragrunt-source-version doesn't match the current version.

func (*TerraformSource) String added in v0.9.7

func (src *TerraformSource) String() string

type TerragruntInfoGroup added in v0.18.5

type TerragruntInfoGroup struct {
	ConfigPath       string
	DownloadDir      string
	IamRole          string
	TerraformBinary  string
	TerraformCommand string
	WorkingDir       string
}

Struct is output as JSON by 'terragrunt-info':

type UnrecognizedCommand added in v0.6.0

type UnrecognizedCommand string

func (UnrecognizedCommand) Error added in v0.6.0

func (commandName UnrecognizedCommand) Error() string

Jump to

Keyboard shortcuts

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