terraform

package
v0.49.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Platform = "terraform"

Platform that relates to this functionality

Variables

This section is empty.

Functions

func ExtractResourcesFromPlan

func ExtractResourcesFromPlan(plan *PlanRepresentation) ([]*core.Resource, error)

ExtractResourcesFromPlan analysis a plan and returns a collection of resources

func UnmarshalTF

func UnmarshalTF(tf []byte, v interface{}) error

UnmarshalTF - unmarshals .tf files by recursively removing unsupported HCL lines, for eg. terraform functions. The theory being that we'll only be interested in policing values we can directly support

Types

type BlockExpressionRepresentation

type BlockExpressionRepresentation struct {
	AMI             *ExpressionRepresentation   `json:"ami"`
	InstanceType    *ExpressionRepresentation   `json:"instance_type"`
	RootBlockDevice *ExpressionRepresentation   `json:"root_block_device"`
	EBSBlockDevice  []*ExpressionRepresentation `json:"ebs_block_device"`
}

type ChangeRepresentation

type ChangeRepresentation struct {
	Actions []string              `json:"actions"`
	Before  *ValuesRepresentation `json:"before"`
	After   *ValuesRepresentation `json:"after"`
}

type ChildModuleRepresentation

type ChildModuleRepresentation struct {
	Address      string                       `json:"address"`
	Resources    []*ResourceRepresentation    `json:"resources"`
	ChildModules []*ChildModuleRepresentation `json:"child_modules"`
}

func (ChildModuleRepresentation) ToModule

type ConfigurationRepresentation

type ConfigurationRepresentation struct {
	ProviderConfigs *ProviderConfigRepresentation               `json:"provider_configs"`
	RootModule      *ModuleConfigRepresentation                 `json:"root_module"`
	ModuleCalls     map[string]*ModuleCallsConfigRepresentation `json:"module_calls"`
}

type ExpressionRepresentation

type ExpressionRepresentation struct {
	ConstantValue string   `json:"constant_value"`
	References    []string `json:"references"`
}

type ModuleCallsConfigRepresentation

type ModuleCallsConfigRepresentation struct {
	ResolvedSource    string                         `json:"resolved_source"`
	Expressions       *BlockExpressionRepresentation `json:"expressions"`
	CountExpression   *ExpressionRepresentation      `json:"count_expression"`
	ForEachExpression *ExpressionRepresentation      `json:"for_each_expression"`
	Module            *ModuleConfigRepresentation    `json:"module"`
}

type ModuleConfigRepresentation

type ModuleConfigRepresentation struct {
	Outputs map[string]struct {
		Expression *ExpressionRepresentation `json:"expression"`
		Sensitive  bool                      `json:"sensitive"`
	} `json:"outputs"`

	Resources []struct {
		Address           string                         `json:"address"`
		Mode              string                         `json:"mode"`
		Type              string                         `json:"type"`
		Name              string                         `json:"name"`
		ProviderConfigKey string                         `json:"provider_config_key"`
		Expressions       *BlockExpressionRepresentation `json:"expressions"`
		SchemaVersion     int                            `json:"schema_version"`
		CountExpression   *ExpressionRepresentation      `json:"count_expression"`
		ForEachExpression *ExpressionRepresentation      `json:"for_each_expression"`
		Provisioners      []struct {
			Type        string                         `json:"type"`
			Expressions *BlockExpressionRepresentation `json:"expressions"`
		} `json:"provisioners"`
	} `json:"resources"`
}

type ModuleRepresentation

type ModuleRepresentation struct {
	Resources    []*ResourceRepresentation    `json:"resources"`
	ChildModules []*ChildModuleRepresentation `json:"child_modules"`
}

type PlanRepresentation

type PlanRepresentation struct {
	FormatVersion   string                           `json:"format_version"`
	PriorState      *StateRepresentation             `json:"prior_state"`
	Configuration   *ConfigurationRepresentation     `json:"configuration"`
	PlannedValues   *ValuesRepresentation            `json:"planned_values"`
	Variables       map[string]map[string]string     `json:"variables"`
	ResourceChanges []*ResourceChangeRepresentation  `json:"resource_changes"`
	OutputChanges   map[string]*ChangeRepresentation `json:"output_changes"`
}

PlanRepresentation document

type ProviderConfigRepresentation

type ProviderConfigRepresentation struct {
	Name          string                         `json:"name"`
	Alias         string                         `json:"alias"`
	ModuleAddress string                         `json:"module_address"`
	Expressions   *BlockExpressionRepresentation `json:"expressions"`
}

type ResourceChangeRepresentation

type ResourceChangeRepresentation struct {
	Address       string                `json:"address"`
	ModuleAddress string                `json:"module_address"`
	Mode          string                `json:"mode"`
	Type          string                `json:"type"`
	Name          string                `json:"name"`
	Index         int                   `json:"index"`
	Deposed       string                `json:"deposed"`
	Change        *ChangeRepresentation `json:"change"`
}

type ResourceRepresentation

type ResourceRepresentation struct {
	Address       string                 `json:"address"`
	Mode          string                 `json:"mode"`
	Type          string                 `json:"type"`
	Name          string                 `json:"name"`
	Index         int                    `json:"index"`
	ProviderName  string                 `json:"provider_name"`
	SchemaVersion int                    `json:"schema_version"`
	Values        map[string]interface{} `json:"values"`
}

type StateRepresentation

type StateRepresentation struct {
	TerraformVersion string                `json:"terraform_version"`
	Values           *ValuesRepresentation `json:"value"`
}

type TFResource

type TFResource struct {
	Label  string                 `json:"label"`
	Type   string                 `json:"type"`
	Values map[string]interface{} `json:"values"`
}

TFResource -type used to create resource input for .tf file scanning

type ValueRepresentation

type ValueRepresentation struct {
	Value     string `json:"string"`
	Sensitive bool   `json:"sensitive"`
}

type ValuesRepresentation

type ValuesRepresentation struct {
	Outputs    map[string]*ValueRepresentation `json:"outputs"`
	RootModule *ModuleRepresentation           `json:"root_module"`
}

Jump to

Keyboard shortcuts

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