Movatterモバイル変換


[0]ホーム

URL:


tfexec

package
v0.24.0Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License:MPL-2.0Imports:23Imported by:247

Details

Repository

github.com/hashicorp/terraform-exec

Links

Documentation

Overview

Package tfexec exposes functionality for constructing and running TerraformCLI commands. Structured return values use the data types defined in thegithub.com/hashicorp/terraform-json package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcCleanEnvadded inv0.12.0

func CleanEnv(dirty map[string]string) map[string]string

CleanEnv removes any prohibited environment variables from an environment map.

funcFormatStringadded inv0.11.0

func FormatString(ctxcontext.Context, execPathstring, contentstring) (string,error)

FormatString formats a passed string, given a path to Terraform.

funcProhibitedEnvadded inv0.12.0

func ProhibitedEnv(env map[string]string) []string

ProhibitedEnv returns a slice of environment variable keys that are not allowedto be set manually from the passed environment.

Types

typeAllowDeferralOptionadded inv0.21.0

type AllowDeferralOption struct {// contains filtered or unexported fields}

AllowDeferralOption represents the -allow-deferral flag. This flag is only enabled inexperimental builds of Terraform. (alpha or built via source with experiments enabled)

funcAllowDeferraladded inv0.21.0

func AllowDeferral(allowDeferralbool) *AllowDeferralOption

AllowDeferral represents the -allow-deferral flag. This flag is only enabled inexperimental builds of Terraform. (alpha or built via source with experiments enabled)

typeAllowMissingConfigOption

type AllowMissingConfigOption struct {// contains filtered or unexported fields}

AllowMissingConfigOption represents the -allow-missing-config flag.

funcAllowMissingConfig

func AllowMissingConfig(allowMissingConfigbool) *AllowMissingConfigOption

AllowMissingConfig represents the -allow-missing-config flag.

typeAllowMissingOptionadded inv0.16.0

type AllowMissingOption struct {// contains filtered or unexported fields}

AllowMissingOption represents the -allow-missing flag.

funcAllowMissingadded inv0.16.0

func AllowMissing(allowMissingbool) *AllowMissingOption

AllowMissing represents the -allow-missing flag.

typeApplyOption

type ApplyOption interface {// contains filtered or unexported methods}

ApplyOption represents options used in the Apply method.

typeBackendConfigOption

type BackendConfigOption struct {// contains filtered or unexported fields}

BackendConfigOption represents the -backend-config flag.

funcBackendConfig

func BackendConfig(backendConfigstring) *BackendConfigOption

BackendConfig represents the -backend-config flag.

typeBackendOption

type BackendOption struct {// contains filtered or unexported fields}

BackendOption represents the -backend flag.

funcBackend

func Backend(backendbool) *BackendOption

Backend represents the -backend flag.

typeBackupOption

type BackupOption struct {// contains filtered or unexported fields}

BackupOption represents the -backup flag.

funcBackup

func Backup(pathstring) *BackupOption

Backup represents the -backup flag.

funcDisableBackupadded inv0.3.0

func DisableBackup() *BackupOption

DisableBackup is a convenience method for Backup("-"), indicating backup state should be disabled.

typeBackupOutOptionadded inv0.12.0

type BackupOutOption struct {// contains filtered or unexported fields}

funcBackupOutadded inv0.12.0

func BackupOut(pathstring) *BackupOutOption

BackupOutOption represents the -backup-out flag.

typeConfigOption

type ConfigOption struct {// contains filtered or unexported fields}

ConfigOption represents the -config flag.

funcConfig

func Config(pathstring) *ConfigOption

Config represents the -config flag.

typeCopyStateOptionadded inv0.8.0

type CopyStateOption struct {// contains filtered or unexported fields}

CopyStateOption represents the -state flag for terraform workspace new. This flag is usedto copy an existing state file in to the new workspace.

funcCopyStateadded inv0.8.0

func CopyState(pathstring) *CopyStateOption

CopyState represents the -state flag for terraform workspace new. This flag is usedto copy an existing state file in to the new workspace.

typeDestroyFlagOption

type DestroyFlagOption struct {// contains filtered or unexported fields}

DestroyFlagOption represents the -destroy flag.

funcDestroy

func Destroy(destroybool) *DestroyFlagOption

Destroy represents the -destroy flag.

typeDestroyOption

type DestroyOption interface {// contains filtered or unexported methods}

DestroyOption represents options used in the Destroy method.

typeDirOptionadded inv0.7.0

type DirOption struct {// contains filtered or unexported fields}

funcDiradded inv0.7.0

func Dir(pathstring) *DirOption

typeDirOrPlanOption

type DirOrPlanOption struct {// contains filtered or unexported fields}

funcDirOrPlan

func DirOrPlan(pathstring) *DirOrPlanOption

typeDrawCyclesOptionadded inv0.16.0

type DrawCyclesOption struct {// contains filtered or unexported fields}

funcDrawCyclesadded inv0.16.0

func DrawCycles(drawCyclesbool) *DrawCyclesOption

DrawCycles represents the -draw-cycles flag.

typeDryRunOptionadded inv0.12.0

type DryRunOption struct {// contains filtered or unexported fields}

funcDryRunadded inv0.12.0

func DryRun(dryRunbool) *DryRunOption

DryRun represents the -dry-run flag.

typeErrManualEnvVaradded inv0.4.0

type ErrManualEnvVar struct {Namestring}

ErrManualEnvVar is returned when an env var that should be set programatically via an option or methodis set via the manual environment passing functions.

func (*ErrManualEnvVar)Erroradded inv0.4.0

func (err *ErrManualEnvVar) Error()string

typeErrNoSuitableBinary

type ErrNoSuitableBinary struct {// contains filtered or unexported fields}

func (*ErrNoSuitableBinary)Error

func (e *ErrNoSuitableBinary) Error()string

func (*ErrNoSuitableBinary)Unwrapadded inv0.13.0

func (e *ErrNoSuitableBinary) Unwrap()error

typeErrVersionMismatch

type ErrVersionMismatch struct {MinInclusivestringMaxExclusivestringActualstring}

ErrVersionMismatch is returned when the detected Terraform version is not compatible with thecommand or flags being used in this invocation.

func (*ErrVersionMismatch)Erroradded inv0.5.0

func (e *ErrVersionMismatch) Error()string

typeFSMirrorOptionadded inv0.15.0

type FSMirrorOption struct {// contains filtered or unexported fields}

funcFSMirroradded inv0.15.0

func FSMirror(fsMirrorstring) *FSMirrorOption

FSMirror represents the -fs-mirror option (path to filesystem mirror directory)

typeForceCopyOption

type ForceCopyOption struct {// contains filtered or unexported fields}

funcForceCopy

func ForceCopy(forceCopybool) *ForceCopyOption

typeForceOptionadded inv0.12.0

type ForceOption struct {// contains filtered or unexported fields}

funcForceadded inv0.12.0

func Force(forcebool) *ForceOption

typeForceUnlockOptionadded inv0.16.0

type ForceUnlockOption interface {// contains filtered or unexported methods}

typeFormatOptionadded inv0.11.0

type FormatOption interface {// contains filtered or unexported methods}

typeFromModuleOption

type FromModuleOption struct {// contains filtered or unexported fields}

funcFromModule

func FromModule(sourcestring) *FromModuleOption

typeGenerateConfigOutOptionadded inv0.24.0

type GenerateConfigOutOption struct {// contains filtered or unexported fields}

funcGenerateConfigOutadded inv0.24.0

func GenerateConfigOut(pathstring) *GenerateConfigOutOption

typeGetCmdOptionadded inv0.14.0

type GetCmdOption interface {// contains filtered or unexported methods}

GetCmdOption represents options used in the Get method.

typeGetOption

type GetOption struct {// contains filtered or unexported fields}

funcGet

func Get(getbool) *GetOption

typeGetPluginsOption

type GetPluginsOption struct {// contains filtered or unexported fields}

funcGetPlugins

func GetPlugins(getPluginsbool) *GetPluginsOption

typeGraphOptionadded inv0.16.0

type GraphOption interface {// contains filtered or unexported methods}

typeGraphPlanOptionadded inv0.16.0

type GraphPlanOption struct {// contains filtered or unexported fields}

funcGraphPlanadded inv0.16.0

func GraphPlan(filestring) *GraphPlanOption

GraphPlan represents the -plan flag which is a specified plan file string

typeGraphTypeOptionadded inv0.16.0

type GraphTypeOption struct {// contains filtered or unexported fields}

funcGraphTypeadded inv0.16.0

func GraphType(graphTypestring) *GraphTypeOption

typeImportOption

type ImportOption interface {// contains filtered or unexported methods}

ImportOption represents options used in the Import method.

typeInitOption

type InitOption interface {// contains filtered or unexported methods}

InitOption represents options used in the Init method.

typeLockOption

type LockOption struct {// contains filtered or unexported fields}

LockOption represents the -lock flag.

funcLock

func Lock(lockbool) *LockOption

Lock represents the -lock flag.

typeLockTimeoutOption

type LockTimeoutOption struct {// contains filtered or unexported fields}

LockTimeoutOption represents the -lock-timeout flag.

funcLockTimeout

func LockTimeout(lockTimeoutstring) *LockTimeoutOption

LockTimeout represents the -lock-timeout flag.

typeNetMirrorOptionadded inv0.15.0

type NetMirrorOption struct {// contains filtered or unexported fields}

funcNetMirroradded inv0.15.0

func NetMirror(netMirrorstring) *NetMirrorOption

NetMirror represents the -net-mirror option (base URL of a network mirror)

typeNextMessageadded inv0.24.0

type NextMessage struct {Msgtfjson.LogMsgErrerror}

typeOutOption

type OutOption struct {// contains filtered or unexported fields}

funcOut

func Out(pathstring) *OutOption

typeOutputMeta

type OutputMeta struct {Sensitivebool            `json:"sensitive"`Typejson.RawMessage `json:"type"`Valuejson.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?

typeOutputOption

type OutputOption interface {// contains filtered or unexported methods}

OutputOption represents options used in the Output method.

typeParallelismOption

type ParallelismOption struct {// contains filtered or unexported fields}

funcParallelism

func Parallelism(nint) *ParallelismOption

typePlanOption

type PlanOption interface {// contains filtered or unexported methods}

PlanOption represents options used in the Plan method.

typePlatformOptionadded inv0.15.0

type PlatformOption struct {// contains filtered or unexported fields}

funcPlatformadded inv0.15.0

func Platform(platformstring) *PlatformOption

Platform represents the -platform flag which is an os_arch string

typePluginDirOption

type PluginDirOption struct {// contains filtered or unexported fields}

funcPluginDir

func PluginDir(pluginDirstring) *PluginDirOption

typeProviderOptionadded inv0.15.0

type ProviderOption struct {// contains filtered or unexported fields}

funcProvideradded inv0.15.0

func Provider(providersstring) *ProviderOption

Provider represents the positional argument (provider source address)

typeProvidersLockOptionadded inv0.15.0

type ProvidersLockOption interface {// contains filtered or unexported methods}

typeQueryOptionadded inv0.24.0

type QueryOption interface {// contains filtered or unexported methods}

QueryOption represents options used in the Query method.

typeReattachConfigadded inv0.9.0

type ReattachConfig struct {ProtocolstringProtocolVersionintPidintTestboolAddrReattachConfigAddr}

ReattachConfig holds the information Terraform needs to be able to attachitself to a provider process, so it can drive the process.

typeReattachConfigAddradded inv0.9.0

type ReattachConfigAddr struct {NetworkstringStringstring}

ReattachConfigAddr is a JSON-encoding friendly version of net.Addr.

typeReattachInfoadded inv0.9.0

type ReattachInfo map[string]ReattachConfig

typeReattachOptionadded inv0.9.0

type ReattachOption struct {// contains filtered or unexported fields}

funcReattachadded inv0.9.0

func Reattach(infoReattachInfo) *ReattachOption

typeReconfigureOption

type ReconfigureOption struct {// contains filtered or unexported fields}

funcReconfigure

func Reconfigure(reconfigurebool) *ReconfigureOption

typeRecursiveOptionadded inv0.11.0

type RecursiveOption struct {// contains filtered or unexported fields}

funcRecursiveadded inv0.11.0

func Recursive(rbool) *RecursiveOption

typeRefreshCmdOptionadded inv0.7.0

type RefreshCmdOption interface {// contains filtered or unexported methods}

RefreshCmdOption represents options used in the Refresh method.

typeRefreshOnlyOptionadded inv0.19.0

type RefreshOnlyOption struct {// contains filtered or unexported fields}

funcRefreshOnlyadded inv0.19.0

func RefreshOnly(refreshOnlybool) *RefreshOnlyOption

typeRefreshOption

type RefreshOption struct {// contains filtered or unexported fields}

funcRefresh

func Refresh(refreshbool) *RefreshOption

typeReplaceOptionadded inv0.15.0

type ReplaceOption struct {// contains filtered or unexported fields}

funcReplaceadded inv0.15.0

func Replace(addressstring) *ReplaceOption

typeShowOptionadded inv0.9.0

type ShowOption interface {// contains filtered or unexported methods}

typeStateMvCmdOptionadded inv0.12.0

type StateMvCmdOption interface {// contains filtered or unexported methods}

StateMvCmdOption represents options used in the Refresh method.

typeStateOption

type StateOption struct {// contains filtered or unexported fields}

funcStatedeprecated

func State(pathstring) *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 thelocal backend.Seehttps://github.com/hashicorp/terraform/issues/25920#issuecomment-676560799

typeStateOutOption

type StateOutOption struct {// contains filtered or unexported fields}

funcStateOut

func StateOut(pathstring) *StateOutOption

typeStatePullOptionadded inv0.17.0

type StatePullOption interface {// contains filtered or unexported methods}

typeStatePushCmdOptionadded inv0.17.0

type StatePushCmdOption interface {// contains filtered or unexported methods}

StatePushCmdOption represents options used in the Refresh method.

typeStateRmCmdOptionadded inv0.13.0

type StateRmCmdOption interface {// contains filtered or unexported methods}

StateRmCmdOption represents options used in the Refresh method.

typeTaintOptionadded inv0.16.0

type TaintOption interface {// contains filtered or unexported methods}

TaintOption represents options used in the Taint method.

typeTargetOption

type TargetOption struct {// contains filtered or unexported fields}

funcTarget

func Target(resourcestring) *TargetOption

typeTerraform

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 configurationbut you can override paths used in some commands depending on the availableoptions.

All functions that execute CLI commands take a context.Context. It should be noted thatexec.Cmd.Run will not return context.DeadlineExceeded or context.Canceled by default, wehave augmented our wrapped errors to respond true to errors.Is for context.DeadlineExceededand context.Canceled if those are present on the context when the error is parsed. Seehttps://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 prohibitssetting 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

funcNewTerraform

func NewTerraform(workingDirstring, execPathstring) (*Terraform,error)

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(ctxcontext.Context, opts ...ApplyOption)error

Apply represents the terraform apply subcommand.

func (*Terraform)ApplyJSONadded inv0.18.0

func (tf *Terraform) ApplyJSON(ctxcontext.Context, wio.Writer, opts ...ApplyOption)error

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 beremoved in a future major version in favour of Apply returning JSON by default.

func (*Terraform)Destroy

func (tf *Terraform) Destroy(ctxcontext.Context, opts ...DestroyOption)error

Destroy represents the terraform destroy subcommand.

func (*Terraform)DestroyJSONadded inv0.18.0

func (tf *Terraform) DestroyJSON(ctxcontext.Context, wio.Writer, opts ...DestroyOption)error

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 beremoved in a future major version in favour of Destroy returning JSON by default.

func (*Terraform)ExecPathadded inv0.5.0

func (tf *Terraform) ExecPath()string

ExecPath returns the path to the Terraform executable.

func (*Terraform)ForceUnlockadded inv0.16.0

func (tf *Terraform) ForceUnlock(ctxcontext.Context, lockIDstring, opts ...ForceUnlockOption)error

ForceUnlock represents the `terraform force-unlock` command

func (*Terraform)Formatadded inv0.12.0

func (tf *Terraform) Format(ctxcontext.Context, unformattedio.Reader, formattedio.Writer)error

Format performs formatting on the unformatted io.Reader (as stdin to the CLI) and returnsthe formatted result on the formatted io.Writer.

func (*Terraform)FormatCheckadded inv0.11.0

func (tf *Terraform) FormatCheck(ctxcontext.Context, opts ...FormatOption) (bool, []string,error)

FormatCheck returns true if the config files in the working or selected (via DirOption) directory are already formatted.

func (*Terraform)FormatStringadded inv0.11.0

func (tf *Terraform) FormatString(ctxcontext.Context, contentstring) (string,error)

FormatString formats a passed string.

func (*Terraform)FormatWriteadded inv0.11.0

func (tf *Terraform) FormatWrite(ctxcontext.Context, opts ...FormatOption)error

FormatWrite attempts to format and modify all config files in the working or selected (via DirOption) directory.

func (*Terraform)Getadded inv0.14.0

func (tf *Terraform) Get(ctxcontext.Context, opts ...GetCmdOption)error

Get represents the terraform get subcommand.

func (*Terraform)Graphadded inv0.16.0

func (tf *Terraform) Graph(ctxcontext.Context, opts ...GraphOption) (string,error)

func (*Terraform)Importadded inv0.2.0

func (tf *Terraform) Import(ctxcontext.Context, address, idstring, opts ...ImportOption)error

Import represents the terraform import subcommand.

func (*Terraform)Init

func (tf *Terraform) Init(ctxcontext.Context, opts ...InitOption)error

Init represents the terraform init subcommand.

func (*Terraform)InitJSONadded inv0.22.0

func (tf *Terraform) InitJSON(ctxcontext.Context, wio.Writer, opts ...InitOption)error

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)MetadataFunctionsadded inv0.18.0

func (tf *Terraform) MetadataFunctions(ctxcontext.Context) (*tfjson.MetadataFunctions,error)

MetadataFunctions represents the terraform metadata functions -json subcommand.

func (*Terraform)Output

func (tf *Terraform) Output(ctxcontext.Context, opts ...OutputOption) (map[string]OutputMeta,error)

Output represents the terraform output subcommand.

func (*Terraform)Plan

func (tf *Terraform) Plan(ctxcontext.Context, opts ...PlanOption) (bool,error)

Plan executes `terraform plan` with the specified options and waits for itto complete.

The returned boolean is false when the plan diff is empty (no changes) andtrue when the plan diff is non-empty (changes present).

The returned error is nil if `terraform plan` has been executed and exitswith either 0 or 2.

func (*Terraform)PlanJSONadded inv0.18.0

func (tf *Terraform) PlanJSON(ctxcontext.Context, wio.Writer, opts ...PlanOption) (bool,error)

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) andtrue when the plan diff is non-empty (changes present).

The returned error is nil if `terraform plan` has been executed and exitswith either 0 or 2.

PlanJSON is likely to be removed in a future major version in favour ofPlan returning JSON by default.

func (*Terraform)ProvidersLockadded inv0.15.0

func (tf *Terraform) ProvidersLock(ctxcontext.Context, opts ...ProvidersLockOption)error

ProvidersLock represents the `terraform providers lock` command

func (*Terraform)ProvidersSchema

func (tf *Terraform) ProvidersSchema(ctxcontext.Context) (*tfjson.ProviderSchemas,error)

ProvidersSchema represents the terraform providers schema -json subcommand.

func (*Terraform)QueryJSONadded inv0.24.0

func (tf *Terraform) QueryJSON(ctxcontext.Context, opts ...QueryOption) (iter.Seq[NextMessage],error)

QueryJSON executes `terraform query` 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 error is nil if `terraform query` has been executed and exitswith 0.

QueryJSON is likely to be removed in a future major version in favour ofquery returning JSON by default.

func (*Terraform)Refreshadded inv0.7.0

func (tf *Terraform) Refresh(ctxcontext.Context, opts ...RefreshCmdOption)error

Refresh represents the terraform refresh subcommand.

func (*Terraform)RefreshJSONadded inv0.18.0

func (tf *Terraform) RefreshJSON(ctxcontext.Context, wio.Writer, opts ...RefreshCmdOption)error

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 beremoved in a future major version in favour of Refresh returning JSON by default.

func (*Terraform)SetAppendUserAgentadded inv0.8.0

func (tf *Terraform) SetAppendUserAgent(uastring)error

SetAppendUserAgent sets the TF_APPEND_USER_AGENT environment variable forTerraform CLI execution.

func (*Terraform)SetDisablePluginTLSadded inv0.9.0

func (tf *Terraform) SetDisablePluginTLS(disabledbool)error

SetDisablePluginTLS sets the TF_DISABLE_PLUGIN_TLS environment variable forTerraform CLI execution.

func (*Terraform)SetEnableLegacyPipeClosingadded inv0.23.1

func (tf *Terraform) SetEnableLegacyPipeClosing(enabledbool)error

SetEnableLegacyPipeClosing causes the library to "force-close" stdio pipes.This works around a bug in Terraform < v1.1 that would otherwise leavethe process (and caller) hanging after graceful shutdown.

This option can be safely ignored (set to false) with Terraform 1.1+.

func (*Terraform)SetEnv

func (tf *Terraform) SetEnv(env map[string]string)error

SetEnv allows you to override environment variables, this should not be used for any well knownTerraform environment variables that are already covered in options. Pass nil to copy the valuesfrom os.Environ. Attempting to set environment variables that should be managed manually willresult in ErrManualEnvVar being returned.

func (*Terraform)SetLogadded inv0.17.0

func (tf *Terraform) SetLog(logstring)error

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 thelog level was unreliable in earlier versions. It will default to TRACE whenSetLogPath is called on versions 0.14.11 and earlier, or if SetLogCore andSetLogProvider have not been called before SetLogPath on versions 0.15.0 andlater.

func (*Terraform)SetLogCoreadded inv0.17.2

func (tf *Terraform) SetLogCore(logCorestring)error

SetLogCore sets the TF_LOG_CORE environment variable for Terraform CLIexecution. 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)SetLogPathadded inv0.4.0

func (tf *Terraform) SetLogPath(pathstring)error

SetLogPath sets the TF_LOG_PATH environment variable for Terraform CLIexecution.

func (*Terraform)SetLogProvideradded inv0.17.2

func (tf *Terraform) SetLogProvider(logProviderstring)error

SetLogProvider sets the TF_LOG_PROVIDER environment variable for TerraformCLI execution. This must be combined with a call to SetLogPath to takeeffect.

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)SetSkipProviderVerifyadded inv0.9.0

func (tf *Terraform) SetSkipProviderVerify(skipbool)error

SetSkipProviderVerify sets the TF_SKIP_PROVIDER_VERIFY environment variablefor Terraform CLI execution. This is no longer used in 0.13.0 and greater.

func (*Terraform)SetStderradded inv0.6.0

func (tf *Terraform) SetStderr(wio.Writer)

SetStderr specifies a writer to stream stderr to for every command.

This should be used for information or logging purposes only, not controlflow. Any parsing necessary should be added as functionality to this package.

func (*Terraform)SetStdoutadded inv0.6.0

func (tf *Terraform) SetStdout(wio.Writer)

SetStdout specifies a writer to stream stdout to for every command.

This should be used for information or logging purposes only, not controlflow. Any parsing necessary should be added as functionality to this package.

func (*Terraform)SetWaitDelayadded inv0.23.0

func (tf *Terraform) SetWaitDelay(delaytime.Duration)error

SetWaitDelay sets the WaitDelay of running Terraform process asexec.Cmd

func (*Terraform)Showadded inv0.3.0

func (tf *Terraform) Show(ctxcontext.Context, opts ...ShowOption) (*tfjson.State,error)

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)ShowPlanFileadded inv0.7.0

func (tf *Terraform) ShowPlanFile(ctxcontext.Context, planPathstring, opts ...ShowOption) (*tfjson.Plan,error)

ShowPlanFile reads a given plan file and outputs the plan.

func (*Terraform)ShowPlanFileRawadded inv0.10.0

func (tf *Terraform) ShowPlanFileRaw(ctxcontext.Context, planPathstring, opts ...ShowOption) (string,error)

ShowPlanFileRaw reads a given plan file and outputs the plan in ahuman-friendly, opaque format.

func (*Terraform)ShowStateFileadded inv0.7.0

func (tf *Terraform) ShowStateFile(ctxcontext.Context, statePathstring, opts ...ShowOption) (*tfjson.State,error)

ShowStateFile reads a given state file and outputs the state.

func (*Terraform)StateMvadded inv0.12.0

func (tf *Terraform) StateMv(ctxcontext.Context, sourcestring, destinationstring, opts ...StateMvCmdOption)error

StateMv represents the terraform state mv subcommand.

func (*Terraform)StatePulladded inv0.17.0

func (tf *Terraform) StatePull(ctxcontext.Context, opts ...StatePullOption) (string,error)

func (*Terraform)StatePushadded inv0.17.0

func (tf *Terraform) StatePush(ctxcontext.Context, pathstring, opts ...StatePushCmdOption)error

func (*Terraform)StateRmadded inv0.13.0

func (tf *Terraform) StateRm(ctxcontext.Context, addressstring, opts ...StateRmCmdOption)error

StateRm represents the terraform state rm subcommand.

func (*Terraform)Taintadded inv0.16.0

func (tf *Terraform) Taint(ctxcontext.Context, addressstring, opts ...TaintOption)error

Taint represents the terraform taint subcommand.

func (*Terraform)Testadded inv0.19.0

func (tf *Terraform) Test(ctxcontext.Context, wio.Writer, opts ...TestOption)error

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)Untaintadded inv0.16.0

func (tf *Terraform) Untaint(ctxcontext.Context, addressstring, opts ...UntaintOption)error

Untaint represents the terraform untaint subcommand.

func (*Terraform)Upgrade012added inv0.12.0

func (tf *Terraform) Upgrade012(ctxcontext.Context, opts ...Upgrade012Option)error

Upgrade012 represents the terraform 0.12upgrade subcommand.

func (*Terraform)Upgrade013added inv0.14.0

func (tf *Terraform) Upgrade013(ctxcontext.Context, opts ...Upgrade013Option)error

Upgrade013 represents the terraform 0.13upgrade subcommand.

func (*Terraform)Validateadded inv0.12.0

func (tf *Terraform) Validate(ctxcontext.Context) (*tfjson.ValidateOutput,error)

Validate represents the validate subcommand to the Terraform CLI. The -jsonflag support was added in 0.12.0, so this will not work on earlier versions.

func (*Terraform)Versionadded inv0.4.0

func (tf *Terraform) Version(ctxcontext.Context, skipCachebool) (tfVersion *version.Version, providerVersions map[string]*version.Version, errerror)

Version returns structured output from the terraform version command including both the Terraform CLI versionand any initialized provider versions. This will read cached values when present unless the skipCache parameteris set to true.

func (*Terraform)WorkingDiradded inv0.5.0

func (tf *Terraform) WorkingDir()string

WorkingDir returns the working directory for Terraform.

func (*Terraform)WorkspaceDeleteadded inv0.16.0

func (tf *Terraform) WorkspaceDelete(ctxcontext.Context, workspacestring, opts ...WorkspaceDeleteCmdOption)error

WorkspaceDelete represents the workspace delete subcommand to the Terraform CLI.

func (*Terraform)WorkspaceListadded inv0.8.0

func (tf *Terraform) WorkspaceList(ctxcontext.Context) ([]string,string,error)

WorkspaceList represents the workspace list subcommand to the Terraform CLI.

func (*Terraform)WorkspaceNewadded inv0.8.0

func (tf *Terraform) WorkspaceNew(ctxcontext.Context, workspacestring, opts ...WorkspaceNewCmdOption)error

WorkspaceNew represents the workspace new subcommand to the Terraform CLI.

func (*Terraform)WorkspaceSelectadded inv0.8.0

func (tf *Terraform) WorkspaceSelect(ctxcontext.Context, workspacestring)error

WorkspaceSelect represents the workspace select subcommand to the Terraform CLI.

func (*Terraform)WorkspaceShowadded inv0.16.0

func (tf *Terraform) WorkspaceShow(ctxcontext.Context) (string,error)

WorkspaceShow represents the workspace show subcommand to the Terraform CLI.

typeTestOptionadded inv0.19.0

type TestOption interface {// contains filtered or unexported methods}

typeTestsDirectoryOptionadded inv0.19.0

type TestsDirectoryOption struct {// contains filtered or unexported fields}

funcTestsDirectoryadded inv0.19.0

func TestsDirectory(testsDirectorystring) *TestsDirectoryOption

TestsDirectory represents the -tests-directory option (path to tests files)

typeUntaintOptionadded inv0.16.0

type UntaintOption interface {// contains filtered or unexported methods}

OutputOption represents options used in the Output method.

typeUpdateOptionadded inv0.14.0

type UpdateOption struct {// contains filtered or unexported fields}

funcUpdateadded inv0.14.0

func Update(updatebool) *UpdateOption

typeUpgrade012Optionadded inv0.12.0

type Upgrade012Option interface {// contains filtered or unexported methods}

Upgrade012Option represents options used in the Destroy method.

typeUpgrade013Optionadded inv0.14.0

type Upgrade013Option interface {// contains filtered or unexported methods}

Upgrade013Option represents options used in the Destroy method.

typeUpgradeOption

type UpgradeOption struct {// contains filtered or unexported fields}

funcUpgrade

func Upgrade(upgradebool) *UpgradeOption

typeUseJSONNumberOptionadded inv0.20.0

type UseJSONNumberOption struct {// contains filtered or unexported fields}

funcJSONNumberadded inv0.20.0

func JSONNumber(useJSONNumberbool) *UseJSONNumberOption

JSONNumber determines how numerical values are handled during JSON decoding.

typeVarFileOption

type VarFileOption struct {// contains filtered or unexported fields}

funcVarFile

func VarFile(pathstring) *VarFileOption

typeVarOption

type VarOption struct {// contains filtered or unexported fields}

funcVar

func Var(assignmentstring) *VarOption

typeVerifyPluginsOption

type VerifyPluginsOption struct {// contains filtered or unexported fields}

funcVerifyPlugins

func VerifyPlugins(verifyPluginsbool) *VerifyPluginsOption

typeWorkspaceDeleteCmdOptionadded inv0.16.0

type WorkspaceDeleteCmdOption interface {// contains filtered or unexported methods}

WorkspaceDeleteCmdOption represents options that are applicable to the WorkspaceDelete method.

typeWorkspaceNewCmdOptionadded inv0.8.0

type WorkspaceNewCmdOption interface {// contains filtered or unexported methods}

WorkspaceNewCmdOption represents options that are applicable to the WorkspaceNew method.

Source Files

View all Source files

Directories

PathSynopsis
internal
e2etest
Package e2etest contains end-to-end acceptance tests for the tfexec package.
Package e2etest contains end-to-end acceptance tests for the tfexec package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp