terraform

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package terraform provides definitions of Terraform resources in JSON format. This intentially does not define all fields in the plan JSON. https://www.terraform.io/docs/internals/json-format.html#plan-representation

Package terraform provides definitions of Terraform resources in JSON format. This intentially does not define all fields in the plan JSON. https://www.terraform.io/docs/internals/json-format.html#plan-representation

Index

Constants

View Source
const StateFileExtension string = ".tfstate"

StateFileExtension is the default extension of Terraform state file.

Variables

This section is empty.

Functions

func GetInstancesForType

func GetInstancesForType(resources []*states.Resource, kind string) ([]map[string]interface{}, error)

GetInstancesForType returns the list of objects for type from given resources list.

func ReadProviderConfigValues

func ReadProviderConfigValues(data []byte, kind, name string) (map[string]interface{}, error)

ReadProviderConfigValues returns the values from the expressions block from the provider config for the resource with the given kind and name. Variable references are resolved, as are constant_value.

func ResourcesFromState

func ResourcesFromState(r io.Reader) ([]*states.Resource, error)

ResourcesFromState reads Terraform resources from the input reader.

func ResourcesFromStateFile

func ResourcesFromStateFile(path string) ([]*states.Resource, error)

ResourcesFromStateFile reads Terraform resources from the input file at path.

Types

type Change

type Change struct {
	Actions []string `json:"actions"`
	// These are "value-representation", not "values-representation" and the keys are resource-specific.
	Before       map[string]interface{} `json:"before"`
	After        map[string]interface{} `json:"after"`
	AfterUnknown map[string]interface{} `json:"after_unknown"` // Undocumented :( See https://github.com/terraform-providers/terraform-provider-aws/issues/11823
}

Change represents the "Change" element of a Terraform resource change from a Terraform plan. https://www.terraform.io/docs/internals/json-format.html#change-representation

type Configuration

type Configuration struct {
	ProviderConfig map[string]ProviderConfig `json:"provider_config"`
	RootModule     struct {
		// Note: This is not the same schema as the planned value resource above.
		Resources []struct {
			Address           string      `json:"address"`
			Kind              string      `json:"type"`
			Name              string      `json:"name"`
			ProviderConfigKey string      `json:"provider_config_key"`
			Expressions       expressions `json:"expressions"`
		} `json:"resources"`
	} `json:"root_module"`
}

Configuration represents part of the configuration block of a plan. https://www.terraform.io/docs/internals/json-format.html#configuration-representation

type ProviderConfig

type ProviderConfig struct {
	Name              string      `json:"name"`
	VersionConstraint string      `json:"version_constraint,omitempty"`
	Alias             string      `json:"alias,omitempty"`
	Expressions       expressions `json:"expressions"`
}

ProviderConfig represents a single provider configuration from the Configuration block of a Terraform plan.

type Resource

type Resource struct {
	Name    string                 `json:"name"`
	Address string                 `json:"address"`
	Kind    string                 `json:"type"`
	Mode    string                 `json:"mode"` // "managed" for resources, or "data" for data resources
	Values  map[string]interface{} `json:"values"`
}

Resource represent single Terraform resource definition.

type ResourceChange

type ResourceChange struct {
	Address       string `json:"address"`
	ModuleAddress string `json:"module_address"`
	Mode          string `json:"mode"` // "managed" for resources, or "data" for data resources
	Kind          string `json:"type"`
	Name          string `json:"name"`
	Change        Change `json:"change"`
}

ResourceChange represents a Terraform resource change from a Terraform plan. See "resource_changes" at https://www.terraform.io/docs/internals/json-format.html#plan-representation

func ReadPlanChanges

func ReadPlanChanges(data []byte, actions []string) ([]ResourceChange, error)

ReadPlanChanges unmarshals b into a jsonPlan and returns the array of ResourceChange from it. If actions is not "", will only return changes where one of the specified actions will be taken.

Jump to

Keyboard shortcuts

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