terraformer

package module
v0.0.0-...-e233a94 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 10 Imported by: 0

README

go-terraform

A package to interact with terraform modules from go.

Documentation

Index

Constants

View Source
const (
	TerraformBin = "terraform"

	// FlagAutoApprove Terraform Flags
	FlagAutoApprove = "-auto-approve"
	FlagForceCopy   = "-force-copy"
	FlagJSON        = "-json"

	// OptionBackendConfig Terraform Options
	OptionBackendConfig = "-backend-config"
	OptionVar           = "-var"
	OptionFromModule    = "-from-module"

	// OperationInit Terraform actions
	OperationInit    = "init"
	OperationApply   = "apply"
	OperationPlan    = "plan"
	OperationDestroy = "destroy"
	OperationState   = "state"
	OperationTaint   = "taint"
	OperationUntaint = "untaint"
	OperationShow    = "show"
	OperationOutput  = "output"

	ArgumentList = "list"
	ArgumentShow = "show"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Execute(command string, args []string, prefix string) (*[]byte, error)
}

type TerraformBackendConfig

type TerraformBackendConfig struct {
}

TerraformBackendConfig is a collection of supported terraform init backend options

type TerraformFlags

type TerraformFlags struct {
	FlagForceCopy bool
}

TerraformFlags is a collection of supported terraform flags

type TerraformOptions

type TerraformOptions struct {
	FromModule bool
}

TerraformOptions is a collection of supported terraform options

type TerraformRunner

type TerraformRunner struct {
	Module    string
	Version   string
	Directory string
	Operation string

	Inputs        map[string]interface{}
	BackendConfig *TerraformBackendConfig
	Options       *TerraformOptions
	Flags         *TerraformFlags

	Writer   io.Writer
	Executor Executor

	PrintOutput bool
	Debug       bool
}

TerraformRunner object is the main object which defines the `terraform` command and how to execute it.

func (*TerraformRunner) GenerateArguments

func (cmd *TerraformRunner) GenerateArguments() ([]string, error)

GenerateArguments method generate the terraform arguments

func (*TerraformRunner) GenerateBackendConfig

func (cmd *TerraformRunner) GenerateBackendConfig() []string

GenerateBackendConfig method generate the terraform arguments for `terraform init`

func (*TerraformRunner) GenerateFlags

func (cmd *TerraformRunner) GenerateFlags() []string

GenerateFlags method generate the terraform flags

func (*TerraformRunner) GenerateInputs

func (cmd *TerraformRunner) GenerateInputs() []string

GenerateInputs method generate the terraform `-var` arguments for `terraform apply, plan, destroy`

func (*TerraformRunner) GenerateOptions

func (cmd *TerraformRunner) GenerateOptions() []string

GenerateOptions method generate the terraform options

func (*TerraformRunner) GetModule

func (cmd *TerraformRunner) GetModule() error

GetModule clones the given repo into a directory

func (*TerraformRunner) Output

func (cmd *TerraformRunner) Output() (*map[string]interface{}, error)

Output returns the output variables of a terraform module by running `terraform output -json`

func (*TerraformRunner) Resource

func (cmd *TerraformRunner) Resource(name string) (interface{}, error)

func (*TerraformRunner) Resources

func (cmd *TerraformRunner) Resources() ([]string, error)

func (*TerraformRunner) Run

func (cmd *TerraformRunner) Run() error

Run method runs the terraform which used externally

func (*TerraformRunner) State

func (cmd *TerraformRunner) State() (*map[string]interface{}, error)

State returns the state of the module by running `terraform show -json`

func (*TerraformRunner) Taint

func (cmd *TerraformRunner) Taint(name string) error

func (*TerraformRunner) UnTaint

func (cmd *TerraformRunner) UnTaint(name string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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