terraform
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package terraform is the representation of a Terraform Module.
It contains:
• Header: Module header found in shape of multi line '*.tf' comments or an entire file
• Footer: Module footer found in shape of multi line '*.tf' comments or an entire file
• Inputs: List of input 'variables' extracted from the Terraform module .tf files
• ModuleCalls: List of 'modules' extracted from the Terraform module .tf files
• Outputs: List of 'outputs' extracted from Terraform module .tf files
• Providers: List of 'providers' extracted from resources used in Terraform module
• Requirements: List of 'requirements' extracted from the Terraform module .tf files
• Resources: List of 'resources' extracted from the Terraform module .tf files
Usage
options := &terraform.Options{ Path: "./examples", ShowHeader: true, HeaderFromFile: "main.tf", ShowFooter: true, FooterFromFile: "footer.md", SortBy: &terraform.SortBy{ Name: true, }, ReadComments: true,}tfmodule, err := terraform.LoadWithOptions(options)if err != nil { log.Fatal(err)}...
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeInput¶
type Input struct {Namestring `json:"name" toml:"name" xml:"name" yaml:"name"`Typetypes.String `json:"type" toml:"type" xml:"type" yaml:"type"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`Defaulttypes.Value `json:"default" toml:"default" xml:"default" yaml:"default"`Requiredbool `json:"required" toml:"required" xml:"required" yaml:"required"`PositionPosition `json:"-" toml:"-" xml:"-" yaml:"-"`}
Input represents a Terraform input.
func (*Input)GetValue¶
GetValue returns JSON representation of the 'Default' value, which is an 'interface'.If 'Default' is a primitive type, the primitive value of 'Default' will be returnedand not the JSON formatted of it.
func (*Input)HasDefault¶
HasDefault indicates if a Terraform variable has a default value set.
typeModule¶
type Module struct {XMLNamexml.Name `json:"-" toml:"-" xml:"module" yaml:"-"`Headerstring `json:"header" toml:"header" xml:"header" yaml:"header"`Footerstring `json:"footer" toml:"footer" xml:"footer" yaml:"footer"`Inputs []*Input `json:"inputs" toml:"inputs" xml:"inputs>input" yaml:"inputs"`ModuleCalls []*ModuleCall `json:"modules" toml:"modules" xml:"modules>module" yaml:"modules"`Outputs []*Output `json:"outputs" toml:"outputs" xml:"outputs>output" yaml:"outputs"`Providers []*Provider `json:"providers" toml:"providers" xml:"providers>provider" yaml:"providers"`Requirements []*Requirement `json:"requirements" toml:"requirements" xml:"requirements>requirement" yaml:"requirements"`Resources []*Resource `json:"resources" toml:"resources" xml:"resources>resource" yaml:"resources"`RequiredInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"`OptionalInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"`}
Module represents a Terraform module. It consists of
funcLoadWithOptions¶
LoadWithOptions returns new instance of Module with all the inputs andoutputs discovered from provided 'path' containing Terraform config
func (*Module)HasModuleCalls¶
HasModuleCalls indicates if the module has modulecalls.
func (*Module)HasOutputs¶
HasOutputs indicates if the module has outputs.
func (*Module)HasProviders¶
HasProviders indicates if the module has providers.
func (*Module)HasRequirements¶
HasRequirements indicates if the module has requirements.
func (*Module)HasResources¶
HasResources indicates if the module has resources.
typeModuleCall¶
type ModuleCall struct {Namestring `json:"name" toml:"name" xml:"name" yaml:"name"`Sourcestring `json:"source" toml:"source" xml:"source" yaml:"source"`Versionstring `json:"version" toml:"version" xml:"version" yaml:"version"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`PositionPosition `json:"-" toml:"-" xml:"-" yaml:"-"`}
ModuleCall represents a submodule called by Terraform module.
func (*ModuleCall)FullName¶
func (mc *ModuleCall) FullName()string
FullName returns full name of the modulecall, with version if available
typeOutput¶
type Output struct {Namestring `json:"name" toml:"name" xml:"name" yaml:"name"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`Valuetypes.Value `json:"value,omitempty" toml:"value,omitempty" xml:"value,omitempty" yaml:"value,omitempty"`Sensitivebool `json:"sensitive,omitempty" toml:"sensitive,omitempty" xml:"sensitive,omitempty" yaml:"sensitive,omitempty"`PositionPosition `json:"-" toml:"-" xml:"-" yaml:"-"`ShowValuebool `json:"-" toml:"-" xml:"-" yaml:"-"`}
Output represents a Terraform output.
func (*Output)GetValue¶
GetValue returns JSON representation of the 'Value', which is an 'interface'.If 'Value' is a primitive type, the primitive value of 'Value' will be returnedand not the JSON formatted of it.
func (*Output)HasDefault¶
HasDefault indicates if a Terraform output has a default value set.
func (*Output)MarshalJSON¶
MarshalJSON custom yaml marshal function to take '--output-values' flag intoconsideration. It means if the flag is not set Value and Sensitive fields areset to 'omitempty', otherwise if output values are being shown 'omitempty' getsexplicitly removed to show even empty and false values.
func (*Output)MarshalXML¶
MarshalXML custom xml marshal function to take '--output-values' flag intoconsideration. It means if the flag is not set Value and Sensitive fieldsare set to 'omitempty', otherwise if output values are being shown 'omitempty'gets explicitly removed to show even empty and false values.
func (*Output)MarshalYAML¶
MarshalYAML custom yaml marshal function to take '--output-values' flag intoconsideration. It means if the flag is not set Value and Sensitive fields areset to 'omitempty', otherwise if output values are being shown 'omitempty' getsexplicitly removed to show even empty and false values.
typePosition¶
type Position struct {Filenamestring `json:"-" toml:"-" xml:"-" yaml:"-"`Lineint `json:"-" toml:"-" xml:"-" yaml:"-"`}
Position represents position of Terraform item (input, output, provider, etc) in a file.
typeProvider¶
type Provider struct {Namestring `json:"name" toml:"name" xml:"name" yaml:"name"`Aliastypes.String `json:"alias" toml:"alias" xml:"alias" yaml:"alias"`Versiontypes.String `json:"version" toml:"version" xml:"version" yaml:"version"`PositionPosition `json:"-" toml:"-" xml:"-" yaml:"-"`}
Provider represents a Terraform output.
typeRequirement¶
type Requirement struct {Namestring `json:"name" toml:"name" xml:"name" yaml:"name"`Versiontypes.String `json:"version" toml:"version" xml:"version" yaml:"version"`}
Requirement represents a requirement for Terraform module.
typeResource¶
type Resource struct {Typestring `json:"type" toml:"type" xml:"type" yaml:"type"`Namestring `json:"name" toml:"name" xml:"name" yaml:"name"`ProviderNamestring `json:"provider" toml:"provider" xml:"provider" yaml:"provider"`ProviderSourcestring `json:"source" toml:"source" xml:"source" yaml:"source"`Modestring `json:"mode" toml:"mode" xml:"mode" yaml:"mode"`Versiontypes.String `json:"version" toml:"version" xml:"version" yaml:"version"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`PositionPosition `json:"-" toml:"-" xml:"-" yaml:"-"`}
Resource represents a managed or data type that is created by the module
func (*Resource)Spec¶
Spec returns the resource spec addresses a specific resource in the config.It takes the form: resource_type.resource_name[resource index]For more details, see:https://www.terraform.io/docs/cli/state/resource-addressing.html#resource-spec