Documentation
¶
Overview ¶
Package tfexec exposes functionality for constructing and running Terraform CLI commands. Structured return values use the data types defined in the github.com/hashicorp/terraform-json package.
Index ¶
- func CleanEnv(dirty map[string]string) map[string]string
- func FormatString(ctx context.Context, execPath string, content string) (string, error)
- func ProhibitedEnv(env map[string]string) []string
- type AllowDeferralOption
- type AllowMissingConfigOption
- type AllowMissingOption
- type ApplyOption
- type BackendConfigOption
- type BackendOption
- type BackupOption
- type BackupOutOption
- type ConfigOption
- type CopyStateOption
- type DestroyFlagOption
- type DestroyOption
- type DirOption
- type DirOrPlanOption
- type DrawCyclesOption
- type DryRunOption
- type ErrManualEnvVar
- type ErrNoSuitableBinary
- type ErrVersionMismatch
- type FSMirrorOption
- type ForceCopyOption
- type ForceOption
- type ForceUnlockOption
- type FormatOption
- type FromModuleOption
- type GetCmdOption
- type GetOption
- type GetPluginsOption
- type GraphOption
- type GraphPlanOption
- type GraphTypeOption
- type ImportOption
- type InitOption
- type LockOption
- type LockTimeoutOption
- type NetMirrorOption
- type OutOption
- type OutputMeta
- type OutputOption
- type ParallelismOption
- type PlanOption
- type PlatformOption
- type PluginDirOption
- type ProviderOption
- type ProvidersLockOption
- type ReattachConfig
- type ReattachConfigAddr
- type ReattachInfo
- type ReattachOption
- type ReconfigureOption
- type RecursiveOption
- type RefreshCmdOption
- type RefreshOnlyOption
- type RefreshOption
- type ReplaceOption
- type ShowOption
- type StateMvCmdOption
- type StateOption
- func State(path string) *StateOptiondeprecated
- type StateOutOption
- type StatePullOption
- type StatePushCmdOption
- type StateRmCmdOption
- type TaintOption
- type TargetOption
- type Terraform
- func (tf *Terraform) Apply(ctx context.Context, opts ...ApplyOption) error
- func (tf *Terraform) ApplyJSON(ctx context.Context, w io.Writer, opts ...ApplyOption) error
- func (tf *Terraform) Destroy(ctx context.Context, opts ...DestroyOption) error
- func (tf *Terraform) DestroyJSON(ctx context.Context, w io.Writer, opts ...DestroyOption) error
- func (tf *Terraform) ExecPath() string
- func (tf *Terraform) ForceUnlock(ctx context.Context, lockID string, opts ...ForceUnlockOption) error
- func (tf *Terraform) Format(ctx context.Context, unformatted io.Reader, formatted io.Writer) error
- func (tf *Terraform) FormatCheck(ctx context.Context, opts ...FormatOption) (bool, []string, error)
- func (tf *Terraform) FormatString(ctx context.Context, content string) (string, error)
- func (tf *Terraform) FormatWrite(ctx context.Context, opts ...FormatOption) error
- func (tf *Terraform) Get(ctx context.Context, opts ...GetCmdOption) error
- func (tf *Terraform) Graph(ctx context.Context, opts ...GraphOption) (string, error)
- func (tf *Terraform) Import(ctx context.Context, address, id string, opts ...ImportOption) error
- func (tf *Terraform) Init(ctx context.Context, opts ...InitOption) error
- func (tf *Terraform) InitJSON(ctx context.Context, w io.Writer, opts ...InitOption) error
- func (tf *Terraform) MetadataFunctions(ctx context.Context) (*tfjson.MetadataFunctions, error)
- func (tf *Terraform) Output(ctx context.Context, opts ...OutputOption) (map[string]OutputMeta, error)
- func (tf *Terraform) Plan(ctx context.Context, opts ...PlanOption) (bool, error)
- func (tf *Terraform) PlanJSON(ctx context.Context, w io.Writer, opts ...PlanOption) (bool, error)
- func (tf *Terraform) ProvidersLock(ctx context.Context, opts ...ProvidersLockOption) error
- func (tf *Terraform) ProvidersSchema(ctx context.Context) (*tfjson.ProviderSchemas, error)
- func (tf *Terraform) Refresh(ctx context.Context, opts ...RefreshCmdOption) error
- func (tf *Terraform) RefreshJSON(ctx context.Context, w io.Writer, opts ...RefreshCmdOption) error
- func (tf *Terraform) SetAppendUserAgent(ua string) error
- func (tf *Terraform) SetDisablePluginTLS(disabled bool) error
- func (tf *Terraform) SetEnv(env map[string]string) error
- func (tf *Terraform) SetLog(log string) error
- func (tf *Terraform) SetLogCore(logCore string) error
- func (tf *Terraform) SetLogPath(path string) error
- func (tf *Terraform) SetLogProvider(logProvider string) error
- func (tf *Terraform) SetLogger(logger printfer)
- func (tf *Terraform) SetSkipProviderVerify(skip bool) error
- func (tf *Terraform) SetStderr(w io.Writer)
- func (tf *Terraform) SetStdout(w io.Writer)
- func (tf *Terraform) SetWaitDelay(delay time.Duration) error
- func (tf *Terraform) Show(ctx context.Context, opts ...ShowOption) (*tfjson.State, error)
- func (tf *Terraform) ShowPlanFile(ctx context.Context, planPath string, opts ...ShowOption) (*tfjson.Plan, error)
- func (tf *Terraform) ShowPlanFileRaw(ctx context.Context, planPath string, opts ...ShowOption) (string, error)
- func (tf *Terraform) ShowStateFile(ctx context.Context, statePath string, opts ...ShowOption) (*tfjson.State, error)
- func (tf *Terraform) StateMv(ctx context.Context, source string, destination string, ...) error
- func (tf *Terraform) StatePull(ctx context.Context, opts ...StatePullOption) (string, error)
- func (tf *Terraform) StatePush(ctx context.Context, path string, opts ...StatePushCmdOption) error
- func (tf *Terraform) StateRm(ctx context.Context, address string, opts ...StateRmCmdOption) error
- func (tf *Terraform) Taint(ctx context.Context, address string, opts ...TaintOption) error
- func (tf *Terraform) Test(ctx context.Context, w io.Writer, opts ...TestOption) error
- func (tf *Terraform) Untaint(ctx context.Context, address string, opts ...UntaintOption) error
- func (tf *Terraform) Upgrade012(ctx context.Context, opts ...Upgrade012Option) error
- func (tf *Terraform) Upgrade013(ctx context.Context, opts ...Upgrade013Option) error
- func (tf *Terraform) Validate(ctx context.Context) (*tfjson.ValidateOutput, error)
- func (tf *Terraform) Version(ctx context.Context, skipCache bool) (tfVersion *version.Version, providerVersions map[string]*version.Version, ...)
- func (tf *Terraform) WorkingDir() string
- func (tf *Terraform) WorkspaceDelete(ctx context.Context, workspace string, opts ...WorkspaceDeleteCmdOption) error
- func (tf *Terraform) WorkspaceList(ctx context.Context) ([]string, string, error)
- func (tf *Terraform) WorkspaceNew(ctx context.Context, workspace string, opts ...WorkspaceNewCmdOption) error
- func (tf *Terraform) WorkspaceSelect(ctx context.Context, workspace string) error
- func (tf *Terraform) WorkspaceShow(ctx context.Context) (string, error)
- type TestOption
- type TestsDirectoryOption
- type UntaintOption
- type UpdateOption
- type Upgrade012Option
- type Upgrade013Option
- type UpgradeOption
- type UseJSONNumberOption
- type VarFileOption
- type VarOption
- type VerifyPluginsOption
- type WorkspaceDeleteCmdOption
- type WorkspaceNewCmdOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanEnv ¶ added in v0.12.0
CleanEnv removes any prohibited environment variables from an environment map.
func FormatString ¶ added in v0.11.0
FormatString formats a passed string, given a path to Terraform.
func ProhibitedEnv ¶ added in v0.12.0
ProhibitedEnv returns a slice of environment variable keys that are not allowed to be set manually from the passed environment.
Types ¶
type AllowDeferralOption ¶ added in v0.21.0
type AllowDeferralOption struct {
// contains filtered or unexported fields
}
AllowDeferralOption represents the -allow-deferral flag. This flag is only enabled in experimental builds of Terraform. (alpha or built via source with experiments enabled)
func AllowDeferral ¶ added in v0.21.0
func AllowDeferral(allowDeferral bool) *AllowDeferralOption
AllowDeferral represents the -allow-deferral flag. This flag is only enabled in experimental builds of Terraform. (alpha or built via source with experiments enabled)
type AllowMissingConfigOption ¶
type AllowMissingConfigOption struct {
// contains filtered or unexported fields
}
AllowMissingConfigOption represents the -allow-missing-config flag.
func AllowMissingConfig ¶
func AllowMissingConfig(allowMissingConfig bool) *AllowMissingConfigOption
AllowMissingConfig represents the -allow-missing-config flag.
type AllowMissingOption ¶ added in v0.16.0
type AllowMissingOption struct {
// contains filtered or unexported fields
}
AllowMissingOption represents the -allow-missing flag.
func AllowMissing ¶ added in v0.16.0
func AllowMissing(allowMissing bool) *AllowMissingOption
AllowMissing represents the -allow-missing flag.
type ApplyOption ¶
type ApplyOption interface {
// contains filtered or unexported methods
}
ApplyOption represents options used in the Apply method.
type BackendConfigOption ¶
type BackendConfigOption struct {
// contains filtered or unexported fields
}
BackendConfigOption represents the -backend-config flag.
func BackendConfig ¶
func BackendConfig(backendConfig string) *BackendConfigOption
BackendConfig represents the -backend-config flag.
type BackendOption ¶
type BackendOption struct {
// contains filtered or unexported fields
}
BackendOption represents the -backend flag.
type BackupOption ¶
type BackupOption struct {
// contains filtered or unexported fields
}
BackupOption represents the -backup flag.
func DisableBackup ¶ added in v0.3.0
func DisableBackup() *BackupOption
DisableBackup is a convenience method for Backup("-"), indicating backup state should be disabled.
type BackupOutOption ¶ added in v0.12.0
type BackupOutOption struct {
// contains filtered or unexported fields
}
func BackupOut ¶ added in v0.12.0
func BackupOut(path string) *BackupOutOption
BackupOutOption represents the -backup-out flag.
type ConfigOption ¶
type ConfigOption struct {
// contains filtered or unexported fields
}
ConfigOption represents the -config flag.
type CopyStateOption ¶ added in v0.8.0
type CopyStateOption struct {
// contains filtered or unexported fields
}
CopyStateOption represents the -state flag for terraform workspace new. This flag is used to copy an existing state file in to the new workspace.
func CopyState ¶ added in v0.8.0
func CopyState(path string) *CopyStateOption
CopyState represents the -state flag for terraform workspace new. This flag is used to copy an existing state file in to the new workspace.
type DestroyFlagOption ¶
type DestroyFlagOption struct {
// contains filtered or unexported fields
}
DestroyFlagOption represents the -destroy flag.
type DestroyOption ¶
type DestroyOption interface {
// contains filtered or unexported methods
}
DestroyOption represents options used in the Destroy method.
type DirOption ¶ added in v0.7.0
type DirOption struct {
// contains filtered or unexported fields
}
type DirOrPlanOption ¶
type DirOrPlanOption struct {
// contains filtered or unexported fields
}
func DirOrPlan ¶
func DirOrPlan(path string) *DirOrPlanOption
type DrawCyclesOption ¶ added in v0.16.0
type DrawCyclesOption struct {
// contains filtered or unexported fields
}
func DrawCycles ¶ added in v0.16.0
func DrawCycles(drawCycles bool) *DrawCyclesOption
DrawCycles represents the -draw-cycles flag.
type DryRunOption ¶ added in v0.12.0
type DryRunOption struct {
// contains filtered or unexported fields
}
func DryRun ¶ added in v0.12.0
func DryRun(dryRun bool) *DryRunOption
DryRun represents the -dry-run flag.
type ErrManualEnvVar ¶ added in v0.4.0
type ErrManualEnvVar struct {
Name string
}
ErrManualEnvVar is returned when an env var that should be set programatically via an option or method is set via the manual environment passing functions.
func (*ErrManualEnvVar) Error ¶ added in v0.4.0
func (err *ErrManualEnvVar) Error() string
type ErrNoSuitableBinary ¶
type ErrNoSuitableBinary struct {
// contains filtered or unexported fields
}
func (*ErrNoSuitableBinary) Error ¶
func (e *ErrNoSuitableBinary) Error() string
func (*ErrNoSuitableBinary) Unwrap ¶ added in v0.13.0
func (e *ErrNoSuitableBinary) Unwrap() error
type ErrVersionMismatch ¶
ErrVersionMismatch is returned when the detected Terraform version is not compatible with the command or flags being used in this invocation.
func (*ErrVersionMismatch) Error ¶ added in v0.5.0
func (e *ErrVersionMismatch) Error() string
type FSMirrorOption ¶ added in v0.15.0
type FSMirrorOption struct {
// contains filtered or unexported fields
}
func FSMirror ¶ added in v0.15.0
func FSMirror(fsMirror string) *FSMirrorOption
FSMirror represents the -fs-mirror option (path to filesystem mirror directory)
type ForceCopyOption ¶
type ForceCopyOption struct {
// contains filtered or unexported fields
}
func ForceCopy ¶
func ForceCopy(forceCopy bool) *ForceCopyOption
type ForceOption ¶ added in v0.12.0
type ForceOption struct {
// contains filtered or unexported fields
}
func Force ¶ added in v0.12.0
func Force(force bool) *ForceOption
type ForceUnlockOption ¶ added in v0.16.0
type ForceUnlockOption interface {
// contains filtered or unexported methods
}
type FormatOption ¶ added in v0.11.0
type FormatOption interface {
// contains filtered or unexported methods
}
type FromModuleOption ¶
type FromModuleOption struct {
// contains filtered or unexported fields
}
func FromModule ¶
func FromModule(source string) *FromModuleOption
type GetCmdOption ¶ added in v0.14.0
type GetCmdOption interface {
// contains filtered or unexported methods
}
GetCmdOption represents options used in the Get method.
type GetPluginsOption ¶
type GetPluginsOption struct {
// contains filtered or unexported fields
}
func GetPlugins ¶
func GetPlugins(getPlugins bool) *GetPluginsOption
type GraphOption ¶ added in v0.16.0
type GraphOption interface {
// contains filtered or unexported methods
}
type GraphPlanOption ¶ added in v0.16.0
type GraphPlanOption struct {
// contains filtered or unexported fields
}
func GraphPlan ¶ added in v0.16.0
func GraphPlan(file string) *GraphPlanOption
GraphPlan represents the -plan flag which is a specified plan file string
type GraphTypeOption ¶ added in v0.16.0
type GraphTypeOption struct {
// contains filtered or unexported fields
}
func GraphType ¶ added in v0.16.0
func GraphType(graphType string) *GraphTypeOption
type ImportOption ¶
type ImportOption interface {
// contains filtered or unexported methods
}
ImportOption represents options used in the Import method.
type InitOption ¶
type InitOption interface {
// contains filtered or unexported methods
}
InitOption represents options used in the Init method.
type LockOption ¶
type LockOption struct {
// contains filtered or unexported fields
}
LockOption represents the -lock flag.
type LockTimeoutOption ¶
type LockTimeoutOption struct {
// contains filtered or unexported fields
}
LockTimeoutOption represents the -lock-timeout flag.
func LockTimeout ¶
func LockTimeout(lockTimeout string) *LockTimeoutOption
LockTimeout represents the -lock-timeout flag.
type NetMirrorOption ¶ added in v0.15.0
type NetMirrorOption struct {
// contains filtered or unexported fields
}
func NetMirror ¶ added in v0.15.0
func NetMirror(netMirror string) *NetMirrorOption
NetMirror represents the -net-mirror option (base URL of a network mirror)
type OutputMeta ¶
type OutputMeta struct { Sensitive bool `json:"sensitive"` Type json.RawMessage `json:"type"` Value json.RawMessage `json:"value"` }
OutputMeta represents the JSON output of 'terraform output -json', which resembles state format version 3 due to a historical accident. Please see hashicorp/terraform/command/output.go. TODO KEM: Should this type be in terraform-json?
type OutputOption ¶
type OutputOption interface {
// contains filtered or unexported methods
}
OutputOption represents options used in the Output method.
type ParallelismOption ¶
type ParallelismOption struct {
// contains filtered or unexported fields
}
func Parallelism ¶
func Parallelism(n int) *ParallelismOption
type PlanOption ¶
type PlanOption interface {
// contains filtered or unexported methods
}
PlanOption represents options used in the Plan method.
type PlatformOption ¶ added in v0.15.0
type PlatformOption struct {
// contains filtered or unexported fields
}
func Platform ¶ added in v0.15.0
func Platform(platform string) *PlatformOption
Platform represents the -platform flag which is an os_arch string
type PluginDirOption ¶
type PluginDirOption struct {
// contains filtered or unexported fields
}
func PluginDir ¶
func PluginDir(pluginDir string) *PluginDirOption
type ProviderOption ¶ added in v0.15.0
type ProviderOption struct {
// contains filtered or unexported fields
}
func Provider ¶ added in v0.15.0
func Provider(providers string) *ProviderOption
Provider represents the positional argument (provider source address)
type ProvidersLockOption ¶ added in v0.15.0
type ProvidersLockOption interface {
// contains filtered or unexported methods
}
type ReattachConfig ¶ added in v0.9.0
type ReattachConfig struct { Protocol string ProtocolVersion int Pid int Test bool Addr ReattachConfigAddr }
ReattachConfig holds the information Terraform needs to be able to attach itself to a provider process, so it can drive the process.
type ReattachConfigAddr ¶ added in v0.9.0
ReattachConfigAddr is a JSON-encoding friendly version of net.Addr.
type ReattachInfo ¶ added in v0.9.0
type ReattachInfo map[string]ReattachConfig
type ReattachOption ¶ added in v0.9.0
type ReattachOption struct {
// contains filtered or unexported fields
}
func Reattach ¶ added in v0.9.0
func Reattach(info ReattachInfo) *ReattachOption
type ReconfigureOption ¶
type ReconfigureOption struct {
// contains filtered or unexported fields
}
func Reconfigure ¶
func Reconfigure(reconfigure bool) *ReconfigureOption
type RecursiveOption ¶ added in v0.11.0
type RecursiveOption struct {
// contains filtered or unexported fields
}
func Recursive ¶ added in v0.11.0
func Recursive(r bool) *RecursiveOption
type RefreshCmdOption ¶ added in v0.7.0
type RefreshCmdOption interface {
// contains filtered or unexported methods
}
RefreshCmdOption represents options used in the Refresh method.
type RefreshOnlyOption ¶ added in v0.19.0
type RefreshOnlyOption struct {
// contains filtered or unexported fields
}
func RefreshOnly ¶ added in v0.19.0
func RefreshOnly(refreshOnly bool) *RefreshOnlyOption
type RefreshOption ¶
type RefreshOption struct {
// contains filtered or unexported fields
}
func Refresh ¶
func Refresh(refresh bool) *RefreshOption
type ReplaceOption ¶ added in v0.15.0
type ReplaceOption struct {
// contains filtered or unexported fields
}
func Replace ¶ added in v0.15.0
func Replace(address string) *ReplaceOption
type ShowOption ¶ added in v0.9.0
type ShowOption interface {
// contains filtered or unexported methods
}
type StateMvCmdOption ¶ added in v0.12.0
type StateMvCmdOption interface {
// contains filtered or unexported methods
}
StateMvCmdOption represents options used in the Refresh method.
type StateOption ¶
type StateOption struct {
// contains filtered or unexported fields
}
func State
deprecated
func State(path string) *StateOption
State represents the -state flag.
Deprecated: The -state CLI flag is a legacy flag and should not be used. If you need a different state file for every run, you can instead use the local backend. See https://github.com/hashicorp/terraform/issues/25920#issuecomment-676560799
type StateOutOption ¶
type StateOutOption struct {
// contains filtered or unexported fields
}
func StateOut ¶
func StateOut(path string) *StateOutOption
type StatePullOption ¶ added in v0.17.0
type StatePullOption interface {
// contains filtered or unexported methods
}
type StatePushCmdOption ¶ added in v0.17.0
type StatePushCmdOption interface {
// contains filtered or unexported methods
}
StatePushCmdOption represents options used in the Refresh method.
type StateRmCmdOption ¶ added in v0.13.0
type StateRmCmdOption interface {
// contains filtered or unexported methods
}
StateRmCmdOption represents options used in the Refresh method.
type TaintOption ¶ added in v0.16.0
type TaintOption interface {
// contains filtered or unexported methods
}
TaintOption represents options used in the Taint method.
type TargetOption ¶
type TargetOption struct {
// contains filtered or unexported fields
}
func Target ¶
func Target(resource string) *TargetOption
type Terraform ¶
type Terraform struct {
// contains filtered or unexported fields
}
Terraform represents the Terraform CLI executable and working directory.
Typically this is constructed against the root module of a Terraform configuration but you can override paths used in some commands depending on the available options.
All functions that execute CLI commands take a context.Context. It should be noted that exec.Cmd.Run will not return context.DeadlineExceeded or context.Canceled by default, we have augmented our wrapped errors to respond true to errors.Is for context.DeadlineExceeded and context.Canceled if those are present on the context when the error is parsed. See https://github.com/golang/go/issues/21880 for more about the Go limitations.
By default, the instance inherits the environment from the calling code (using os.Environ) but it ignores certain environment variables that are managed within the code and prohibits setting them through SetEnv:
- TF_APPEND_USER_AGENT
- TF_IN_AUTOMATION
- TF_INPUT
- TF_LOG
- TF_LOG_PATH
- TF_REATTACH_PROVIDERS
- TF_DISABLE_PLUGIN_TLS
- TF_SKIP_PROVIDER_VERIFY
func NewTerraform ¶
NewTerraform returns a Terraform struct with default values for all fields. If a blank execPath is supplied, NewTerraform will error. Use hc-install or output from os.LookPath to get a desirable execPath.
func (*Terraform) Apply ¶
func (tf *Terraform) Apply(ctx context.Context, opts ...ApplyOption) error
Apply represents the terraform apply subcommand.
func (*Terraform) ApplyJSON ¶ added in v0.18.0
ApplyJSON represents the terraform apply subcommand with the `-json` flag. Using the `-json` flag will result in [machine-readable](https://developer.hashicorp.com/terraform/internals/machine-readable-ui) JSON being written to the supplied `io.Writer`. ApplyJSON is likely to be removed in a future major version in favour of Apply returning JSON by default.
func (*Terraform) Destroy ¶
func (tf *Terraform) Destroy(ctx context.Context, opts ...DestroyOption) error
Destroy represents the terraform destroy subcommand.
func (*Terraform) DestroyJSON ¶ added in v0.18.0
DestroyJSON represents the terraform destroy subcommand with the `-json` flag. Using the `-json` flag will result in [machine-readable](https://developer.hashicorp.com/terraform/internals/machine-readable-ui) JSON being written to the supplied `io.Writer`. DestroyJSON is likely to be removed in a future major version in favour of Destroy returning JSON by default.
func (*Terraform) ForceUnlock ¶ added in v0.16.0
func (tf *Terraform) ForceUnlock(ctx context.Context, lockID string, opts ...ForceUnlockOption) error
ForceUnlock represents the `terraform force-unlock` command
func (*Terraform) Format ¶ added in v0.12.0
Format performs formatting on the unformatted io.Reader (as stdin to the CLI) and returns the formatted result on the formatted io.Writer.
func (*Terraform) FormatCheck ¶ added in v0.11.0
FormatCheck returns true if the config files in the working or selected (via DirOption) directory are already formatted.
func (*Terraform) FormatString ¶ added in v0.11.0
FormatString formats a passed string.
func (*Terraform) FormatWrite ¶ added in v0.11.0
func (tf *Terraform) FormatWrite(ctx context.Context, opts ...FormatOption) error
FormatWrite attempts to format and modify all config files in the working or selected (via DirOption) directory.
func (*Terraform) Get ¶ added in v0.14.0
func (tf *Terraform) Get(ctx context.Context, opts ...GetCmdOption) error
Get represents the terraform get subcommand.
func (*Terraform) Init ¶
func (tf *Terraform) Init(ctx context.Context, opts ...InitOption) error
Init represents the terraform init subcommand.
func (*Terraform) InitJSON ¶ added in v0.22.0
InitJSON represents the terraform init subcommand with the `-json` flag. Using the `-json` flag will result in [machine-readable](https://developer.hashicorp.com/terraform/internals/machine-readable-ui) JSON being written to the supplied `io.Writer`.
func (*Terraform) MetadataFunctions ¶ added in v0.18.0
MetadataFunctions represents the terraform metadata functions -json subcommand.
func (*Terraform) Output ¶
func (tf *Terraform) Output(ctx context.Context, opts ...OutputOption) (map[string]OutputMeta, error)
Output represents the terraform output subcommand.
func (*Terraform) Plan ¶
Plan executes `terraform plan` with the specified options and waits for it to complete.
The returned boolean is false when the plan diff is empty (no changes) and true when the plan diff is non-empty (changes present).
The returned error is nil if `terraform plan` has been executed and exits with either 0 or 2.
func (*Terraform) PlanJSON ¶ added in v0.18.0
PlanJSON executes `terraform plan` with the specified options as well as the `-json` flag and waits for it to complete.
Using the `-json` flag will result in [machine-readable](https://developer.hashicorp.com/terraform/internals/machine-readable-ui) JSON being written to the supplied `io.Writer`.
The returned boolean is false when the plan diff is empty (no changes) and true when the plan diff is non-empty (changes present).
The returned error is nil if `terraform plan` has been executed and exits with either 0 or 2.
PlanJSON is likely to be removed in a future major version in favour of Plan returning JSON by default.
func (*Terraform) ProvidersLock ¶ added in v0.15.0
func (tf *Terraform) ProvidersLock(ctx context.Context, opts ...ProvidersLockOption) error
ProvidersLock represents the `terraform providers lock` command
func (*Terraform) ProvidersSchema ¶
ProvidersSchema represents the terraform providers schema -json subcommand.
func (*Terraform) Refresh ¶ added in v0.7.0
func (tf *Terraform) Refresh(ctx context.Context, opts ...RefreshCmdOption) error
Refresh represents the terraform refresh subcommand.
func (*Terraform) RefreshJSON ¶ added in v0.18.0
RefreshJSON represents the terraform refresh subcommand with the `-json` flag. Using the `-json` flag will result in [machine-readable](https://developer.hashicorp.com/terraform/internals/machine-readable-ui) JSON being written to the supplied `io.Writer`. RefreshJSON is likely to be removed in a future major version in favour of Refresh returning JSON by default.
func (*Terraform) SetAppendUserAgent ¶ added in v0.8.0
SetAppendUserAgent sets the TF_APPEND_USER_AGENT environment variable for Terraform CLI execution.
func (*Terraform) SetDisablePluginTLS ¶ added in v0.9.0
SetDisablePluginTLS sets the TF_DISABLE_PLUGIN_TLS environment variable for Terraform CLI execution.
func (*Terraform) SetEnv ¶
SetEnv allows you to override environment variables, this should not be used for any well known Terraform environment variables that are already covered in options. Pass nil to copy the values from os.Environ. Attempting to set environment variables that should be managed manually will result in ErrManualEnvVar being returned.
func (*Terraform) SetLog ¶ added in v0.17.0
SetLog sets the TF_LOG environment variable for Terraform CLI execution. This must be combined with a call to SetLogPath to take effect.
This is only compatible with Terraform CLI 0.15.0 or later as setting the log level was unreliable in earlier versions. It will default to TRACE when SetLogPath is called on versions 0.14.11 and earlier, or if SetLogCore and SetLogProvider have not been called before SetLogPath on versions 0.15.0 and later.
func (*Terraform) SetLogCore ¶ added in v0.17.2
SetLogCore sets the TF_LOG_CORE environment variable for Terraform CLI execution. This must be combined with a call to SetLogPath to take effect.
This is only compatible with Terraform CLI 0.15.0 or later.
func (*Terraform) SetLogPath ¶ added in v0.4.0
SetLogPath sets the TF_LOG_PATH environment variable for Terraform CLI execution.
func (*Terraform) SetLogProvider ¶ added in v0.17.2
SetLogProvider sets the TF_LOG_PROVIDER environment variable for Terraform CLI execution. This must be combined with a call to SetLogPath to take effect.
This is only compatible with Terraform CLI 0.15.0 or later.
func (*Terraform) SetLogger ¶
func (tf *Terraform) SetLogger(logger printfer)
SetLogger specifies a logger for tfexec to use.
func (*Terraform) SetSkipProviderVerify ¶ added in v0.9.0
SetSkipProviderVerify sets the TF_SKIP_PROVIDER_VERIFY environment variable for Terraform CLI execution. This is no longer used in 0.13.0 and greater.
func (*Terraform) SetStderr ¶ added in v0.6.0
SetStderr specifies a writer to stream stderr to for every command.
This should be used for information or logging purposes only, not control flow. Any parsing necessary should be added as functionality to this package.
func (*Terraform) SetStdout ¶ added in v0.6.0
SetStdout specifies a writer to stream stdout to for every command.
This should be used for information or logging purposes only, not control flow. Any parsing necessary should be added as functionality to this package.
func (*Terraform) SetWaitDelay ¶ added in v0.23.0
SetWaitDelay sets the WaitDelay of running Terraform process as exec.Cmd
func (*Terraform) Show ¶ added in v0.3.0
Show reads the default state path and outputs the state. To read a state or plan file, ShowState or ShowPlan must be used instead.
func (*Terraform) ShowPlanFile ¶ added in v0.7.0
func (tf *Terraform) ShowPlanFile(ctx context.Context, planPath string, opts ...ShowOption) (*tfjson.Plan, error)
ShowPlanFile reads a given plan file and outputs the plan.
func (*Terraform) ShowPlanFileRaw ¶ added in v0.10.0
func (tf *Terraform) ShowPlanFileRaw(ctx context.Context, planPath string, opts ...ShowOption) (string, error)
ShowPlanFileRaw reads a given plan file and outputs the plan in a human-friendly, opaque format.
func (*Terraform) ShowStateFile ¶ added in v0.7.0
func (tf *Terraform) ShowStateFile(ctx context.Context, statePath string, opts ...ShowOption) (*tfjson.State, error)
ShowStateFile reads a given state file and outputs the state.
func (*Terraform) StateMv ¶ added in v0.12.0
func (tf *Terraform) StateMv(ctx context.Context, source string, destination string, opts ...StateMvCmdOption) error
StateMv represents the terraform state mv subcommand.
func (*Terraform) Test ¶ added in v0.19.0
Test represents the terraform test -json subcommand.
The given io.Writer, if specified, will receive [machine-readable](https://developer.hashicorp.com/terraform/internals/machine-readable-ui) JSON from Terraform including test results.
func (*Terraform) Upgrade012 ¶ added in v0.12.0
func (tf *Terraform) Upgrade012(ctx context.Context, opts ...Upgrade012Option) error
Upgrade012 represents the terraform 0.12upgrade subcommand.
func (*Terraform) Upgrade013 ¶ added in v0.14.0
func (tf *Terraform) Upgrade013(ctx context.Context, opts ...Upgrade013Option) error
Upgrade013 represents the terraform 0.13upgrade subcommand.
func (*Terraform) Validate ¶ added in v0.12.0
Validate represents the validate subcommand to the Terraform CLI. The -json flag support was added in 0.12.0, so this will not work on earlier versions.
func (*Terraform) Version ¶ added in v0.4.0
func (tf *Terraform) Version(ctx context.Context, skipCache bool) (tfVersion *version.Version, providerVersions map[string]*version.Version, err error)
Version returns structured output from the terraform version command including both the Terraform CLI version and any initialized provider versions. This will read cached values when present unless the skipCache parameter is set to true.
func (*Terraform) WorkingDir ¶ added in v0.5.0
WorkingDir returns the working directory for Terraform.
func (*Terraform) WorkspaceDelete ¶ added in v0.16.0
func (tf *Terraform) WorkspaceDelete(ctx context.Context, workspace string, opts ...WorkspaceDeleteCmdOption) error
WorkspaceDelete represents the workspace delete subcommand to the Terraform CLI.
func (*Terraform) WorkspaceList ¶ added in v0.8.0
WorkspaceList represents the workspace list subcommand to the Terraform CLI.
func (*Terraform) WorkspaceNew ¶ added in v0.8.0
func (tf *Terraform) WorkspaceNew(ctx context.Context, workspace string, opts ...WorkspaceNewCmdOption) error
WorkspaceNew represents the workspace new subcommand to the Terraform CLI.
func (*Terraform) WorkspaceSelect ¶ added in v0.8.0
WorkspaceSelect represents the workspace select subcommand to the Terraform CLI.
type TestOption ¶ added in v0.19.0
type TestOption interface {
// contains filtered or unexported methods
}
type TestsDirectoryOption ¶ added in v0.19.0
type TestsDirectoryOption struct {
// contains filtered or unexported fields
}
func TestsDirectory ¶ added in v0.19.0
func TestsDirectory(testsDirectory string) *TestsDirectoryOption
TestsDirectory represents the -tests-directory option (path to tests files)
type UntaintOption ¶ added in v0.16.0
type UntaintOption interface {
// contains filtered or unexported methods
}
OutputOption represents options used in the Output method.
type UpdateOption ¶ added in v0.14.0
type UpdateOption struct {
// contains filtered or unexported fields
}
func Update ¶ added in v0.14.0
func Update(update bool) *UpdateOption
type Upgrade012Option ¶ added in v0.12.0
type Upgrade012Option interface {
// contains filtered or unexported methods
}
Upgrade012Option represents options used in the Destroy method.
type Upgrade013Option ¶ added in v0.14.0
type Upgrade013Option interface {
// contains filtered or unexported methods
}
Upgrade013Option represents options used in the Destroy method.
type UpgradeOption ¶
type UpgradeOption struct {
// contains filtered or unexported fields
}
func Upgrade ¶
func Upgrade(upgrade bool) *UpgradeOption
type UseJSONNumberOption ¶ added in v0.20.0
type UseJSONNumberOption struct {
// contains filtered or unexported fields
}
func JSONNumber ¶ added in v0.20.0
func JSONNumber(useJSONNumber bool) *UseJSONNumberOption
JSONNumber determines how numerical values are handled during JSON decoding.
type VarFileOption ¶
type VarFileOption struct {
// contains filtered or unexported fields
}
func VarFile ¶
func VarFile(path string) *VarFileOption
type VerifyPluginsOption ¶
type VerifyPluginsOption struct {
// contains filtered or unexported fields
}
func VerifyPlugins ¶
func VerifyPlugins(verifyPlugins bool) *VerifyPluginsOption
type WorkspaceDeleteCmdOption ¶ added in v0.16.0
type WorkspaceDeleteCmdOption interface {
// contains filtered or unexported methods
}
WorkspaceDeleteCmdOption represents options that are applicable to the WorkspaceDelete method.
type WorkspaceNewCmdOption ¶ added in v0.8.0
type WorkspaceNewCmdOption interface {
// contains filtered or unexported methods
}
WorkspaceNewCmdOption represents options that are applicable to the WorkspaceNew method.
Source Files
¶
- apply.go
- cmd.go
- cmd_linux.go
- destroy.go
- doc.go
- errors.go
- fmt.go
- force_unlock.go
- get.go
- graph.go
- import.go
- init.go
- metadata_functions.go
- options.go
- output.go
- plan.go
- providers_lock.go
- providers_schema.go
- refresh.go
- show.go
- state_mv.go
- state_pull.go
- state_push.go
- state_rm.go
- taint.go
- terraform.go
- test.go
- untaint.go
- upgrade012.go
- upgrade013.go
- validate.go
- version.go
- workspace_delete.go
- workspace_list.go
- workspace_new.go
- workspace_select.go
- workspace_show.go