Documentation ¶
Index ¶
- Variables
- func Cmd(opts *CmdOptions, args ...string) ([]byte, error)
- func CreateConfigFile(dir string, terraformCloudHost string, terraformCloudToken string) (string, error)
- func GetUsageOnlyResources() []string
- func HasSupportedProvider(rType string) bool
- func IsTerraformDir(path string) bool
- func NewDirProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
- func NewPlanProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
- func NewStateJSONProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
- func NewTerragruntHCLProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
- func NewTerragruntProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
- func ReadPlanCache(p *DirProvider) ([]byte, error)
- func StripSetupTerraformWrapper(b []byte) ([]byte, bool)
- func UsePlanCache(p *DirProvider) bool
- func WritePlanCache(p *DirProvider, planJSON []byte)
- type CmdError
- type CmdOptions
- type Configuration
- type DirProvider
- type HCLProvider
- func (p *HCLProvider) AddMetadata(metadata *schema.ProjectMetadata)
- func (p *HCLProvider) DisplayType() string
- func (p *HCLProvider) InvalidateCache() *HCLProvider
- func (p *HCLProvider) LoadPlanJSONs() ([]hclProject, error)
- func (p *HCLProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)
- func (p *HCLProvider) Modules() ([]*hcl.Module, error)
- func (p *HCLProvider) Type() string
- type HCLProviderConfig
- type MalformedRegistryURLErr
- type ModuleCall
- type ModuleConfig
- type ModuleDownloadErr
- type ModuleOut
- type Parser
- type PlanJSONProvider
- func (p *PlanJSONProvider) AddMetadata(metadata *schema.ProjectMetadata)
- func (p *PlanJSONProvider) DisplayType() string
- func (p *PlanJSONProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)
- func (p *PlanJSONProvider) LoadResourcesFromSrc(usage map[string]*schema.UsageData, j []byte, spinner *ui.Spinner) (*schema.Project, error)
- func (p *PlanJSONProvider) Type() string
- type PlanModule
- type PlanProvider
- type PlanSchema
- type ProviderConfig
- type RegistryAPIErr
- type ResourceChange
- type ResourceChangesJSON
- type ResourceData
- type ResourceJSON
- type ResourceOutput
- type ResourceRegistryMap
- type RunShowOptions
- type ServiceDiscoveryErr
- type StateJSONProvider
- type TerraformRegistryGetter
- func (tfrGetter *TerraformRegistryGetter) ClientMode(u *url.URL) (getter.ClientMode, error)
- func (tfrGetter *TerraformRegistryGetter) Context() context.Context
- func (tfrGetter *TerraformRegistryGetter) Get(dstPath string, srcURL *url.URL) error
- func (tfrGetter *TerraformRegistryGetter) GetFile(dst string, src *url.URL) error
- func (tfrGetter *TerraformRegistryGetter) SetClient(client *getter.Client)
- type TerraformRegistryServicePath
- type TerragruntHCLProvider
- type TerragruntInfo
- type TerragruntProvider
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCloudToken = errors.New("invalid Terraform Cloud Token")
var ErrMissingCloudToken = errors.New("no Terraform Cloud token is set")
Functions ¶
func CreateConfigFile ¶ added in v0.7.10
func GetUsageOnlyResources ¶ added in v0.7.12
func GetUsageOnlyResources() []string
func HasSupportedProvider ¶ added in v0.7.3
func IsTerraformDir ¶ added in v0.8.0
func NewDirProvider ¶ added in v0.8.0
func NewDirProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
func NewPlanProvider ¶ added in v0.8.0
func NewPlanProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
func NewStateJSONProvider ¶ added in v0.8.0
func NewStateJSONProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
func NewTerragruntHCLProvider ¶ added in v0.9.23
func NewTerragruntHCLProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
NewTerragruntHCLProvider creates a new provider intialized with the configured project path (usually the terragrunt root directory).
func NewTerragruntProvider ¶ added in v0.9.7
func NewTerragruntProvider(ctx *config.ProjectContext, includePastResources bool) schema.Provider
func ReadPlanCache ¶ added in v0.9.12
func ReadPlanCache(p *DirProvider) ([]byte, error)
func StripSetupTerraformWrapper ¶ added in v0.9.14
StripSetupTerraformWrapper removes any output added from the setup-terraform GitHub action terraform wrapper, so we can parse the output of this as valid JSON. It returns the stripped out JSON and a boolean that is true if the wrapper output was found and removed.
func UsePlanCache ¶ added in v0.9.12
func UsePlanCache(p *DirProvider) bool
func WritePlanCache ¶ added in v0.9.12
func WritePlanCache(p *DirProvider, planJSON []byte)
Types ¶
type CmdError ¶ added in v0.6.3
type CmdError struct { Stderr []byte // contains filtered or unexported fields }
type CmdOptions ¶ added in v0.6.2
type Configuration ¶ added in v0.9.19
type Configuration struct { ProviderConfig map[string]ProviderConfig `json:"provider_config"` RootModule ModuleConfig `json:"root_module"` }
type DirProvider ¶ added in v0.8.0
type DirProvider struct { Path string IsTerragrunt bool PlanFlags string InitFlags string Workspace string UseState bool TerraformBinary string TerraformCloudHost string TerraformCloudToken string Env map[string]string // contains filtered or unexported fields }
func (*DirProvider) AddMetadata ¶ added in v0.9.0
func (p *DirProvider) AddMetadata(metadata *schema.ProjectMetadata)
func (*DirProvider) DisplayType ¶ added in v0.8.0
func (p *DirProvider) DisplayType() string
func (*DirProvider) LoadResources ¶ added in v0.8.0
func (*DirProvider) Type ¶ added in v0.8.0
func (p *DirProvider) Type() string
type HCLProvider ¶ added in v0.9.19
type HCLProvider struct {
// contains filtered or unexported fields
}
func NewHCLProvider ¶ added in v0.9.19
func NewHCLProvider(ctx *config.ProjectContext, config *HCLProviderConfig, opts ...hcl.Option) (*HCLProvider, error)
NewHCLProvider returns a HCLProvider with a hcl.Parser initialised using the config.ProjectContext. It will use input flags from either the terraform-plan-flags or top level var and var-file flags to set input vars and files on the underlying hcl.Parser.
func (*HCLProvider) AddMetadata ¶ added in v0.9.19
func (p *HCLProvider) AddMetadata(metadata *schema.ProjectMetadata)
func (*HCLProvider) DisplayType ¶ added in v0.9.19
func (p *HCLProvider) DisplayType() string
func (*HCLProvider) InvalidateCache ¶ added in v0.10.0
func (p *HCLProvider) InvalidateCache() *HCLProvider
InvalidateCache removes the module cache from the prior hcl parse.
func (*HCLProvider) LoadPlanJSONs ¶ added in v0.10.0
func (p *HCLProvider) LoadPlanJSONs() ([]hclProject, error)
LoadPlanJSONs parses the found directories and return the blocks in Terraform plan JSON format.
func (*HCLProvider) LoadResources ¶ added in v0.9.19
LoadResources calls a hcl.Parser to parse the directory config files into hcl.Blocks. It then builds a shallow representation of the terraform plan JSON files from these Blocks, this is passed to the PlanJSONProvider. The PlanJSONProvider uses this shallow representation to actually load Infracost resources.
func (*HCLProvider) Modules ¶ added in v0.10.0
func (p *HCLProvider) Modules() ([]*hcl.Module, error)
Modules parses the found directories into hcl modules representing a config tree of Terraform information. Modules returns the raw hcl blocks associated with each found Terraform project. This can be used to fetch raw information like outputs, vars, resources, e.t.c.
func (*HCLProvider) Type ¶ added in v0.9.19
func (p *HCLProvider) Type() string
type HCLProviderConfig ¶ added in v0.10.0
type MalformedRegistryURLErr ¶ added in v0.9.23
type MalformedRegistryURLErr struct {
// contains filtered or unexported fields
}
MalformedRegistryURLErr is returned if the Terraform Registry URL passed to the Getter is malformed.
func (MalformedRegistryURLErr) Error ¶ added in v0.9.23
func (err MalformedRegistryURLErr) Error() string
type ModuleCall ¶ added in v0.9.19
type ModuleCall struct { Source string `json:"source"` ModuleConfig ModuleConfig `json:"module"` }
type ModuleConfig ¶ added in v0.9.22
type ModuleConfig struct { Resources []ResourceData `json:"resources,omitempty"` ModuleCalls map[string]ModuleCall `json:"module_calls,omitempty"` }
type ModuleDownloadErr ¶ added in v0.9.23
type ModuleDownloadErr struct {
// contains filtered or unexported fields
}
ModuleDownloadErr is returned if Terragrunt failed to download the module.
func (ModuleDownloadErr) Error ¶ added in v0.9.23
func (err ModuleDownloadErr) Error() string
type ModuleOut ¶ added in v0.9.22
type ModuleOut struct { PlanModule PlanModule ModuleConfig ModuleConfig }
type PlanJSONProvider ¶ added in v0.8.0
type PlanJSONProvider struct { Path string // contains filtered or unexported fields }
func NewPlanJSONProvider ¶ added in v0.8.0
func NewPlanJSONProvider(ctx *config.ProjectContext, includePastResources bool) *PlanJSONProvider
func (*PlanJSONProvider) AddMetadata ¶ added in v0.9.0
func (p *PlanJSONProvider) AddMetadata(metadata *schema.ProjectMetadata)
func (*PlanJSONProvider) DisplayType ¶ added in v0.8.0
func (p *PlanJSONProvider) DisplayType() string
func (*PlanJSONProvider) LoadResources ¶ added in v0.8.0
func (*PlanJSONProvider) LoadResourcesFromSrc ¶ added in v0.9.19
func (*PlanJSONProvider) Type ¶ added in v0.8.0
func (p *PlanJSONProvider) Type() string
type PlanModule ¶ added in v0.9.22
type PlanModule struct { Resources []ResourceJSON `json:"resources,omitempty"` Address *string `json:"address,omitempty"` ChildModules []PlanModule `json:"child_modules,omitempty"` }
type PlanProvider ¶ added in v0.8.0
type PlanProvider struct { *DirProvider Path string // contains filtered or unexported fields }
func (*PlanProvider) DisplayType ¶ added in v0.8.0
func (p *PlanProvider) DisplayType() string
func (*PlanProvider) LoadResources ¶ added in v0.8.0
func (*PlanProvider) Type ¶ added in v0.8.0
func (p *PlanProvider) Type() string
type PlanSchema ¶ added in v0.9.19
type PlanSchema struct { FormatVersion string `json:"format_version"` TerraformVersion string `json:"terraform_version"` Variables interface{} `json:"variables,omitempty"` PlannedValues struct { RootModule PlanModule `json:"root_module"` } `json:"planned_values"` ResourceChanges []ResourceChangesJSON `json:"resource_changes"` Configuration Configuration `json:"configuration"` }
type ProviderConfig ¶ added in v0.9.19
type RegistryAPIErr ¶ added in v0.9.23
type RegistryAPIErr struct {
// contains filtered or unexported fields
}
RegistryAPIErr is returned if we get an unsuccessful HTTP return code from the registry.
func (RegistryAPIErr) Error ¶ added in v0.9.23
func (err RegistryAPIErr) Error() string
type ResourceChange ¶ added in v0.9.19
type ResourceChangesJSON ¶ added in v0.9.19
type ResourceData ¶ added in v0.9.19
type ResourceData struct { Address string `json:"address"` Mode string `json:"mode"` Type string `json:"type"` Name string `json:"name"` ProviderConfigKey string `json:"provider_config_key"` Expressions map[string]interface{} `json:"expressions,omitempty"` SchemaVersion int `json:"schema_version"` CountExpression *countExpression `json:"count_expression,omitempty"` }
type ResourceJSON ¶ added in v0.9.19
type ResourceJSON struct { Address string `json:"address"` Mode string `json:"mode"` Type string `json:"type"` Name string `json:"name"` Index *int64 `json:"index,omitempty"` SchemaVersion int `json:"schema_version"` Values map[string]interface{} `json:"values"` InfracostMetadata map[string]interface{} `json:"infracost_metadata"` }
type ResourceOutput ¶ added in v0.9.22
type ResourceOutput struct { Planned ResourceJSON Changes ResourceChangesJSON Configuration ResourceData }
type ResourceRegistryMap ¶ added in v0.6.3
type ResourceRegistryMap map[string]*schema.RegistryItem
func GetResourceRegistryMap ¶ added in v0.6.0
func GetResourceRegistryMap() *ResourceRegistryMap
func (*ResourceRegistryMap) GetCustomRefIDFunc ¶ added in v0.9.19
func (r *ResourceRegistryMap) GetCustomRefIDFunc(resourceDataType string) schema.ReferenceIDFunc
func (*ResourceRegistryMap) GetDefaultRefIDFunc ¶ added in v0.10.0
func (r *ResourceRegistryMap) GetDefaultRefIDFunc(resourceDataType string) schema.ReferenceIDFunc
func (*ResourceRegistryMap) GetReferenceAttributes ¶ added in v0.9.19
func (r *ResourceRegistryMap) GetReferenceAttributes(resourceDataType string) []string
type RunShowOptions ¶ added in v0.9.7
type RunShowOptions struct {
CmdOptions *CmdOptions
}
type ServiceDiscoveryErr ¶ added in v0.9.23
type ServiceDiscoveryErr struct {
// contains filtered or unexported fields
}
ServiceDiscoveryErr is returned if Terragrunt failed to identify the module API endpoint through the service discovery protocol.
func (ServiceDiscoveryErr) Error ¶ added in v0.9.23
func (err ServiceDiscoveryErr) Error() string
type StateJSONProvider ¶ added in v0.8.0
type StateJSONProvider struct { Path string // contains filtered or unexported fields }
func (*StateJSONProvider) AddMetadata ¶ added in v0.9.0
func (p *StateJSONProvider) AddMetadata(metadata *schema.ProjectMetadata)
func (*StateJSONProvider) DisplayType ¶ added in v0.8.0
func (p *StateJSONProvider) DisplayType() string
func (*StateJSONProvider) LoadResources ¶ added in v0.8.0
func (*StateJSONProvider) Type ¶ added in v0.8.0
func (p *StateJSONProvider) Type() string
type TerraformRegistryGetter ¶ added in v0.9.23
type TerraformRegistryGetter struct {
// contains filtered or unexported fields
}
TerraformRegistryGetter is a Getter (from go-getter) implementation that will download from the terraform module registry. This supports getter URLs encoded in the following manner:
tfr://REGISTRY_DOMAIN/MODULE_PATH?version=VERSION
Where the REGISTRY_DOMAIN is the terraform registry endpoint (e.g., registry.terraform.io), MODULE_PATH is the registry path for the module (e.g., terraform-aws-modules/vpc/aws), and VERSION is the specific version of the module to download (e.g., 2.2.0).
This protocol will use the Module Registry Protocol (documented at https://www.terraform.io/docs/internals/module-registry-protocol.html) to lookup the module source URL and download it.
Authentication to private module registries is handled via environment variables. The authorization API token is expected to be provided to Terragrunt via the TG_TF_REGISTRY_TOKEN environment variable. This token can be any registry API token generated on Terraform Cloud / Enterprise.
MAINTAINER'S NOTE: Ideally we implement the full credential system that terraform uses as part of `terraform login`, but all the relevant packages are internal to the terraform repository, thus making it difficult to use as a library. For now, we keep things simple by supporting providing tokens via env vars and in the future, we can consider implementing functionality to load credentials from terraform. GH issue: https://github.com/gruntwork-io/terragrunt/issues/1771
MAINTAINER'S NOTE: Ideally we can support a shorthand notation that omits the tfr:// protocol to detect that it is referring to a terraform registry, but this requires implementing a complex detector and ensuring it has precedence over the file detector. We deferred the implementation for that to a future release. GH issue: https://github.com/gruntwork-io/terragrunt/issues/1772
func (*TerraformRegistryGetter) ClientMode ¶ added in v0.9.23
func (tfrGetter *TerraformRegistryGetter) ClientMode(u *url.URL) (getter.ClientMode, error)
ClientMode returns the download mode based on the given URL. Since this getter is designed around the Terraform module registry, we always use Dir mode so that we can download the full Terraform module.
func (*TerraformRegistryGetter) Context ¶ added in v0.9.23
func (tfrGetter *TerraformRegistryGetter) Context() context.Context
Context returns the go context to use for the underlying fetch routines. This depends on what client is set.
func (*TerraformRegistryGetter) Get ¶ added in v0.9.23
func (tfrGetter *TerraformRegistryGetter) Get(dstPath string, srcURL *url.URL) error
Get is the main routine to fetch the module contents specified at the given URL and download it to the dstPath. This routine assumes that the srcURL points to the Terraform registry URL, with the Path configured to the module path encoded as `:namespace/:name/:system` as expected by the Terraform registry. Note that the URL query parameter must have the `version` key to specify what version to download.
func (*TerraformRegistryGetter) GetFile ¶ added in v0.9.23
func (tfrGetter *TerraformRegistryGetter) GetFile(dst string, src *url.URL) error
GetFile is not implemented for the Terraform module registry Getter since the terraform module registry doesn't serve a single file.
func (*TerraformRegistryGetter) SetClient ¶ added in v0.9.23
func (tfrGetter *TerraformRegistryGetter) SetClient(client *getter.Client)
SetClient allows the getter to know what getter client (different from the underlying HTTP client) to use for progress tracking.
type TerraformRegistryServicePath ¶ added in v0.9.23
type TerraformRegistryServicePath struct {
ModulesPath string `json:"modules.v1"`
}
TerraformRegistryServicePath is a struct for extracting the modules service path in the Registry.
type TerragruntHCLProvider ¶ added in v0.9.23
type TerragruntHCLProvider struct { Path string // contains filtered or unexported fields }
func (*TerragruntHCLProvider) AddMetadata ¶ added in v0.9.23
func (p *TerragruntHCLProvider) AddMetadata(metadata *schema.ProjectMetadata)
func (*TerragruntHCLProvider) DisplayType ¶ added in v0.9.23
func (p *TerragruntHCLProvider) DisplayType() string
func (*TerragruntHCLProvider) LoadResources ¶ added in v0.9.23
func (p *TerragruntHCLProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)
LoadResources finds any Terragrunt projects, prepares them by downloading any required source files, then process each with an HCLProvider.
func (*TerragruntHCLProvider) Type ¶ added in v0.9.23
func (p *TerragruntHCLProvider) Type() string
type TerragruntInfo ¶ added in v0.9.7
type TerragruntProvider ¶ added in v0.9.7
type TerragruntProvider struct { Path string TerragruntFlags string *DirProvider // contains filtered or unexported fields }
func (*TerragruntProvider) AddMetadata ¶ added in v0.9.7
func (p *TerragruntProvider) AddMetadata(metadata *schema.ProjectMetadata)
func (*TerragruntProvider) DisplayType ¶ added in v0.9.7
func (p *TerragruntProvider) DisplayType() string
func (*TerragruntProvider) LoadResources ¶ added in v0.9.7
func (*TerragruntProvider) Type ¶ added in v0.9.7
func (p *TerragruntProvider) Type() string