terraform

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 10 Imported by: 0

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

Documentation

Overview

Package terraform provides convenience utilities for working with the terraform command line tool programatically.

Index

Constants

View Source
const (
	ErrTerraformInit     = "failed to perform terraform init"
	ErrTerraformValidate = "failed to perform terraform validate"
	ErrTerraformGraph    = "failed to perform terraform graph"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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.

Jump to

Keyboard shortcuts

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