# README
terraform
import "github.com/slalombuild/fusion/terraform"
Package terraform provides convenience utilities for working with the terraform command line tool programatically.
Index
Constants
const (
ErrTerraformInit = "failed to perform terraform init"
ErrTerraformValidate = "failed to perform terraform validate"
ErrTerraformGraph = "failed to perform terraform graph"
)
type Terraform
type Terraform struct {
// contains filtered or unexported fields
}
func New
func New(ctx context.Context, workingDir string) (*Terraform, error)
New creates a new instance of the Terraform library with error logging, initialization, and a terraform executable fallback built-in.
func (*Terraform) Cleanup
func (t *Terraform) Cleanup() error
Cleanup cleans the temporary directories created during terraform execution
func (*Terraform) Graph
func (t *Terraform) Graph(w io.Writer) error
Graph initalizes and converts valid terraform into a GraphViz visualization.
func (*Terraform) RenderTemplate
func (t *Terraform) RenderTemplate(r templates.Renderer) error
RenderTemplate renders the terraform template to the temp dir and cleans up after
func (*Terraform) Validate
func (t *Terraform) Validate() error
Validate validates terraform in the working directory.
Example
package main
import (
"context"
"github.com/slalombuild/fusion/templates/aws"
"github.com/slalombuild/fusion/terraform"
"log"
)
func main() {
// Create a new terraform instance
tf, err := terraform.New(context.Background(), ".")
if err != nil {
log.Fatal(err)
}
// Build a new lambda function
lambda := aws.NewLambdaFunction("foo", "index.js", "handler", "GO1.X")
// Render the template to the terraform temp dir
err = tf.RenderTemplate(lambda)
if err != nil {
log.Fatal(err)
}
// Validate terraform in temp dir
err = tf.Validate()
if err != nil {
log.Fatal(err)
}
}
Generated by gomarkdoc
# Functions
New creates a new instance of the Terraform library with error logging, initialization, and a terraform executable fallback built-in.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author