Documentation ¶
Overview ¶
Package terraform allows to interact with Terraform.
Index ¶
- func Apply(t *testing.T, options *Options) string
- func ApplyE(t *testing.T, options *Options) (string, error)
- func Destroy(t *testing.T, options *Options) string
- func DestroyE(t *testing.T, options *Options) (string, error)
- func FormatArgs(customVars map[string]interface{}, args ...string) []string
- func FormatTerraformVarsAsArgs(vars map[string]interface{}) []string
- func Get(t *testing.T, options *Options) string
- func GetE(t *testing.T, options *Options) (string, error)
- func Init(t *testing.T, options *Options) string
- func InitAndApply(t *testing.T, options *Options) string
- func InitAndApplyE(t *testing.T, options *Options) (string, error)
- func InitE(t *testing.T, options *Options) (string, error)
- func Output(t *testing.T, options *Options, key string) string
- func OutputE(t *testing.T, options *Options, key string) (string, error)
- func OutputRequired(t *testing.T, options *Options, key string) string
- func OutputRequiredE(t *testing.T, options *Options, key string) (string, error)
- func RunTerraformCommand(t *testing.T, options *Options, args ...string) string
- func RunTerraformCommandE(t *testing.T, options *Options, args ...string) (string, error)
- type EmptyOutput
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply runs terraform apply with the given options and return stdout/stderr. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func ApplyE ¶
ApplyE runs terraform apply with the given options and return stdout/stderr. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func FormatArgs ¶
FormatArgs converts the inputs to a format palatable to terraform. This includes converting the given vars to the format the Terraform CLI expects (-var key=value).
func FormatTerraformVarsAsArgs ¶
FormatTerraformVarsAsArgs formats the given variables as command-line args for Terraform (e.g. of the format -var key=value).
func InitAndApply ¶
InitAndApply runs terraform init and apply with the given options and return stdout/stderr from the apply command. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func InitAndApplyE ¶
InitAndApplyE runs terraform init and apply with the given options and return stdout/stderr from the apply command. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func OutputRequired ¶
OutputRequired calls terraform output for the given variable and return its value. If the value is empty, fail the test.
func OutputRequiredE ¶
OutputRequiredE calls terraform output for the given variable and return its value. If the value is empty, return an error.
func RunTerraformCommand ¶ added in v0.9.2
RunTerraformCommand runs terraform with the given arguments and options and return stdout/stderr.
Types ¶
type EmptyOutput ¶
type EmptyOutput string
EmptyOutput is an error that occurs when an output is empty.
func (EmptyOutput) Error ¶
func (outputName EmptyOutput) Error() string
type Options ¶
type Options struct { TerraformDir string // The path to the folder where the Terraform code is defined. Vars map[string]interface{} // The vars to pass to Terraform commands using the -var option. EnvVars map[string]string // Environment variables to set when running Terraform RetryableTerraformErrors map[string]string // If Terraform apply fails with one of these (transient) errors, retry. The keys are text to look for in the error and the message is what to display to a user if that error is found. MaxRetries int // Maximum number of times to retry errors matching RetryableTerraformErrors TimeBetweenRetries time.Duration // The amount of time to wait between retries Upgrade bool // Whether the -upgrade flag of the terraform init command should be set to true or not NoColor bool // Whether the -no-color flag will be set for any Terraform command or not }
Options for running Terraform commands