terraform

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TerraformStateOutputsKey = "outputs"

TerraformStateOutputsKey is the key for the terraform state outputs

Variables

View Source
var (
	// CheckovPolicyTemplate is the default template used to produce a checkov configuration
	CheckovPolicyTemplate = `` /* 441-byte string literal not displayed */

)

checkovPolicyTemplate is the default template used to produce a checkov configuration

View Source
var (
	// Detectors is the error detection pattern
	Detectors = map[string][]ErrorDetection{
		"aws": {
			{
				Regex:   "operation error STS: GetCallerIdentity",
				Message: "AWS Credentials in provider has been missconfigured, contact platform administrator",
			},
		},
		"google":  {},
		"azurerm": {},
		"*": {
			{
				Regex:   "error validating provider credentials",
				Message: "Provider credentials are missconfigured, please contact the platform administrator",
			},
		},
	}
)
View Source
var KubernetesBackendTemplate = `` /* 340-byte string literal not displayed */

KubernetesBackendTemplate is responsible for creating the kubernetes backend terraform configuration

Functions

func Decode

func Decode(state []byte) ([]byte, error)

Decode decodes the terraform state returning the json output

func FindChangesInLogs

func FindChangesInLogs(in io.Reader) (bool, error)

FindChangesInLogs is used to scan the logs for the terraform line which informs on changes

func NewCheckovPolicy added in v0.4.0

func NewCheckovPolicy(data map[string]interface{}) ([]byte, error)

NewCheckovPolicy generates a checkov policy from the configuration

func NewKubernetesBackend

func NewKubernetesBackend(options BackendOptions) ([]byte, error)

NewKubernetesBackend creates a new kubernetes backend

func NewTerraformProvider

func NewTerraformProvider(provider string, configuration []byte) ([]byte, error)

NewTerraformProvider generates a terraform provider configuration

func Template added in v0.3.7

func Template(main string, data interface{}) ([]byte, error)

Template renders the content but includes the hcl method

func ToHCL added in v0.3.7

func ToHCL(data interface{}) (string, error)

ToHCL converts the json to HCL format

Types

type BackendOptions added in v0.3.1

type BackendOptions struct {
	// Configuration is a reference to the terraform configuration
	Configuration *terraformv1alpha1.Configuration
	// Namespace is a reference to the controller namespace
	Namespace string
	// Suffix is an expexted suffix for the terraform state
	Suffix string
	// Template is the golang template to use to generate the backend content
	Template string
}

BackendOptions are the options used to generate the backend

type ErrorDetection

type ErrorDetection struct {
	// Regex is the string we are looking for
	Regex string
	// Message is cause of the error
	Message string
}

ErrorDetection defines an error and potential causes for it.

type OutputValue

type OutputValue struct {
	// Value is the value of the output
	Value interface{} `json:"value,omitempty"`
}

OutputValue is a value of the terraform output

func (*OutputValue) String

func (o *OutputValue) String() string

String returns an string representation of the value

type Resource

type Resource struct {
	// Mode is the mode of the resource
	Mode string `json:"mode,omitempty"`
	// Type is the type of the resource
	Type string `json:"type,omitempty"`
	// Instances a collection of the resource instances in the state
	Instances []map[string]interface{} `json:"instances,omitempty"`
}

Resource represents a resource in the state

type State

type State struct {
	// Outputs are the terraform outputs
	Outputs map[string]OutputValue `json:"outputs"`
	// Resources is a collection of resources in the state
	Resources []Resource `json:"resources,omitempty"`
	// TerraformVersion is the version of terraform used
	TerraformVersion string `json:"terraform_version,omitempty"`
}

State is the state of the terraform

func DecodeState

func DecodeState(in []byte) (*State, error)

DecodeState decodes the terraform state outputs

func (*State) CountResources

func (s *State) CountResources() int

CountResources returns the number of managed resources from the state

func (*State) HasOutputs

func (s *State) HasOutputs() bool

HasOutputs returns true if the state has outputs

Jump to

Keyboard shortcuts

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