Documentation ¶
Overview ¶
Package addrs contains types that represent "addresses", which are references to specific objects within a Terraform configuration or state.
All addresses have string representations based on HCL traversal syntax which should be used in the user-interface, and also in-memory representations that can be used internally.
For object types that exist within Terraform modules a pair of types is used. The "local" part of the address is represented by a type, and then an absolute path to that object in the context of its module is represented by a type of the same name with an "Abs" prefix added, for "absolute".
All types within this package should be treated as immutable, even if this is not enforced by the Go compiler. It is always an implementation error to modify an address object in-place after it is initially constructed.
Index ¶
- Constants
- func InstanceKeyLess(i, j InstanceKey) bool
- type AbsInputVariableInstance
- type AbsLocalValue
- type AbsOutputValue
- type AbsProviderConfig
- type AbsResource
- type AbsResourceInstance
- type CountAttr
- type ForEachAttr
- type InputVariable
- type InstanceKey
- type InstanceKeyType
- type IntKey
- type LocalValue
- type Module
- type ModuleCall
- type ModuleCallInstance
- type ModuleCallOutput
- type ModuleInstance
- func (m ModuleInstance) Ancestors() []ModuleInstance
- func (m ModuleInstance) Call() (ModuleInstance, ModuleCall)
- func (m ModuleInstance) CallInstance() (ModuleInstance, ModuleCallInstance)
- func (m ModuleInstance) Child(name string, key InstanceKey) ModuleInstance
- func (m ModuleInstance) Equal(o ModuleInstance) bool
- func (m ModuleInstance) InputVariable(name string) AbsInputVariableInstance
- func (m ModuleInstance) IsAncestor(o ModuleInstance) bool
- func (m ModuleInstance) IsRoot() bool
- func (m ModuleInstance) Less(o ModuleInstance) bool
- func (m ModuleInstance) LocalValue(name string) AbsLocalValue
- func (m ModuleInstance) OutputValue(name string) AbsOutputValue
- func (m ModuleInstance) Parent() ModuleInstance
- func (m ModuleInstance) ProviderConfigAliased(name, alias string) AbsProviderConfig
- func (m ModuleInstance) ProviderConfigDefault(name string) AbsProviderConfig
- func (m ModuleInstance) Resource(mode ResourceMode, typeName string, name string) AbsResource
- func (m ModuleInstance) ResourceInstance(mode ResourceMode, typeName string, name string, key InstanceKey) AbsResourceInstance
- func (m ModuleInstance) String() string
- func (m ModuleInstance) TargetContains(other Targetable) bool
- type ModuleInstanceStep
- type OutputValue
- type PathAttr
- type ProviderConfig
- type Reference
- type Referenceable
- type Resource
- func (r Resource) Absolute(module ModuleInstance) AbsResource
- func (r Resource) DefaultProviderConfig() ProviderConfig
- func (r Resource) Equal(o Resource) bool
- func (r Resource) Instance(key InstanceKey) ResourceInstance
- func (r Resource) Phase(rpt ResourceInstancePhaseType) ResourcePhase
- func (r Resource) String() string
- type ResourceInstance
- func (r ResourceInstance) Absolute(module ModuleInstance) AbsResourceInstance
- func (r ResourceInstance) ContainingResource() Resource
- func (r ResourceInstance) Equal(o ResourceInstance) bool
- func (r ResourceInstance) Phase(rpt ResourceInstancePhaseType) ResourceInstancePhase
- func (r ResourceInstance) String() string
- type ResourceInstancePhase
- type ResourceInstancePhaseType
- type ResourceMode
- type ResourcePhase
- type StringKey
- type Target
- type Targetable
- type TerraformAttr
Constants ¶
const Self selfT = 0
Self is the address of the special object "self" that behaves as an alias for a containing object currently in scope.
Variables ¶
This section is empty.
Functions ¶
func InstanceKeyLess ¶
func InstanceKeyLess(i, j InstanceKey) bool
InstanceKeyLess returns true if the first given instance key i should sort before the second key j, and false otherwise.
Types ¶
type AbsInputVariableInstance ¶
type AbsInputVariableInstance struct { Module ModuleInstance Variable InputVariable }
AbsInputVariableInstance is the address of an input variable within a particular module instance.
func (AbsInputVariableInstance) String ¶
func (v AbsInputVariableInstance) String() string
type AbsLocalValue ¶
type AbsLocalValue struct { Module ModuleInstance LocalValue LocalValue }
AbsLocalValue is the absolute address of a local value within a module instance.
func (AbsLocalValue) String ¶
func (v AbsLocalValue) String() string
type AbsOutputValue ¶
type AbsOutputValue struct { Module ModuleInstance OutputValue OutputValue }
AbsOutputValue is the absolute address of an output value within a module instance.
This represents an output globally within the namespace of a particular configuration. It is related to but separate from ModuleCallOutput, which represents a module output from the perspective of its parent module.
func (AbsOutputValue) ModuleCallOutput ¶
func (v AbsOutputValue) ModuleCallOutput() (ModuleInstance, ModuleCallOutput)
ModuleCallOutput converts an AbsModuleOutput into a ModuleCallOutput, returning also the module instance that the ModuleCallOutput is relative to.
The root module does not have a call, and so this method cannot be used with outputs in the root module, and will panic in that case.
func (AbsOutputValue) String ¶
func (v AbsOutputValue) String() string
type AbsProviderConfig ¶
type AbsProviderConfig struct { Module ModuleInstance ProviderConfig ProviderConfig }
AbsProviderConfig is the absolute address of a provider configuration within a particular module instance.
func ParseAbsProviderConfig ¶
func ParseAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags.Diagnostics)
ParseAbsProviderConfig parses the given traversal as an absolute provider address. The following are examples of traversals that can be successfully parsed as absolute provider configuration addresses:
provider.aws provider.aws.foo module.bar.provider.aws module.bar.module.baz.provider.aws.foo module.foo[1].provider.aws.foo
This type of address is used, for example, to record the relationships between resources and provider configurations in the state structure. This type of address is not generally used in the UI, except in error messages that refer to provider configurations.
func ParseAbsProviderConfigStr ¶
func ParseAbsProviderConfigStr(str string) (AbsProviderConfig, tfdiags.Diagnostics)
ParseAbsProviderConfigStr is a helper wrapper around ParseAbsProviderConfig that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
This should be used only in specialized situations since it will cause the created references to not have any meaningful source location information. If a reference string is coming from a source that should be identified in error messages then the caller should instead parse it directly using a suitable function from the HCL API and pass the traversal itself to ParseAbsProviderConfig.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned the returned address is invalid.
func (AbsProviderConfig) Inherited ¶
func (pc AbsProviderConfig) Inherited() (AbsProviderConfig, bool)
Inherited returns an address that the receiving configuration address might inherit from in a parent module. The second bool return value indicates if such inheritance is possible, and thus whether the returned address is valid.
Inheritance is possible only for default (un-aliased) providers in modules other than the root module. Even if a valid address is returned, inheritence may not be performed for other reasons, such as if the calling module provided explicit provider configurations within the call for this module. The ProviderTransformer graph transform in the main terraform module has the authoritative logic for provider inheritance, and this method is here mainly just for its benefit.
func (AbsProviderConfig) String ¶
func (pc AbsProviderConfig) String() string
type AbsResource ¶
type AbsResource struct { Module ModuleInstance Resource Resource // contains filtered or unexported fields }
AbsResource is an absolute address for a resource under a given module path.
func ParseAbsResource ¶
func ParseAbsResource(traversal hcl.Traversal) (AbsResource, tfdiags.Diagnostics)
ParseAbsResource attempts to interpret the given traversal as an absolute resource address, using the same syntax as expected by ParseTarget.
If no error diagnostics are returned, the returned target includes the address that was extracted and the source range it was extracted from.
If error diagnostics are returned then the AbsResource value is invalid and must not be used.
func ParseAbsResourceStr ¶
func ParseAbsResourceStr(str string) (AbsResource, tfdiags.Diagnostics)
ParseAbsResourceStr is a helper wrapper around ParseAbsResource that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned the returned address may be incomplete.
Since this function has no context about the source of the given string, any returned diagnostics will not have meaningful source location information.
func (AbsResource) Equal ¶
func (r AbsResource) Equal(o AbsResource) bool
func (AbsResource) Instance ¶
func (r AbsResource) Instance(key InstanceKey) AbsResourceInstance
Instance produces the address for a specific instance of the receiver that is idenfied by the given key.
func (AbsResource) String ¶
func (r AbsResource) String() string
func (AbsResource) TargetContains ¶
func (r AbsResource) TargetContains(other Targetable) bool
TargetContains implements Targetable by returning true if the given other address is either equal to the receiver or is an instance of the receiver.
type AbsResourceInstance ¶
type AbsResourceInstance struct { Module ModuleInstance Resource ResourceInstance // contains filtered or unexported fields }
AbsResourceInstance is an absolute address for a resource instance under a given module path.
func ParseAbsResourceInstance ¶
func ParseAbsResourceInstance(traversal hcl.Traversal) (AbsResourceInstance, tfdiags.Diagnostics)
ParseAbsResourceInstance attempts to interpret the given traversal as an absolute resource instance address, using the same syntax as expected by ParseTarget.
If no error diagnostics are returned, the returned target includes the address that was extracted and the source range it was extracted from.
If error diagnostics are returned then the AbsResource value is invalid and must not be used.
func ParseAbsResourceInstanceStr ¶
func ParseAbsResourceInstanceStr(str string) (AbsResourceInstance, tfdiags.Diagnostics)
ParseAbsResourceInstanceStr is a helper wrapper around ParseAbsResourceInstance that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned the returned address may be incomplete.
Since this function has no context about the source of the given string, any returned diagnostics will not have meaningful source location information.
func (AbsResourceInstance) ContainingResource ¶
func (r AbsResourceInstance) ContainingResource() AbsResource
ContainingResource returns the address of the resource that contains the receving resource instance. In other words, it discards the key portion of the address to produce an AbsResource value.
func (AbsResourceInstance) Equal ¶
func (r AbsResourceInstance) Equal(o AbsResourceInstance) bool
func (AbsResourceInstance) Less ¶
func (r AbsResourceInstance) Less(o AbsResourceInstance) bool
Less returns true if the receiver should sort before the given other value in a sorted list of addresses.
func (AbsResourceInstance) String ¶
func (r AbsResourceInstance) String() string
func (AbsResourceInstance) TargetContains ¶
func (r AbsResourceInstance) TargetContains(other Targetable) bool
TargetContains implements Targetable by returning true if the given other address is equal to the receiver.
type CountAttr ¶
type CountAttr struct { Name string // contains filtered or unexported fields }
CountAttr is the address of an attribute of the "count" object in the interpolation scope, like "count.index".
type ForEachAttr ¶ added in v0.12.6
type ForEachAttr struct { Name string // contains filtered or unexported fields }
ForEachAttr is the address of an attribute referencing the current "for_each" object in the interpolation scope, addressed using the "each" keyword, ex. "each.key" and "each.value"
func (ForEachAttr) String ¶ added in v0.12.6
func (f ForEachAttr) String() string
type InputVariable ¶
type InputVariable struct { Name string // contains filtered or unexported fields }
InputVariable is the address of an input variable.
func (InputVariable) String ¶
func (v InputVariable) String() string
type InstanceKey ¶
type InstanceKey interface { String() string // contains filtered or unexported methods }
InstanceKey represents the key of an instance within an object that contains multiple instances due to using "count" or "for_each" arguments in configuration.
IntKey and StringKey are the two implementations of this type. No other implementations are allowed. The single instance of an object that _isn't_ using "count" or "for_each" is represented by NoKey, which is a nil InstanceKey.
var NoKey InstanceKey
NoKey represents the absense of an InstanceKey, for the single instance of a configuration object that does not use "count" or "for_each" at all.
func ParseInstanceKey ¶
func ParseInstanceKey(key cty.Value) (InstanceKey, error)
ParseInstanceKey returns the instance key corresponding to the given value, which must be known and non-null.
If an unknown or null value is provided then this function will panic. This function is intended to deal with the values that would naturally be found in a hcl.TraverseIndex, which (when parsed from source, at least) can never contain unknown or null values.
type InstanceKeyType ¶
type InstanceKeyType rune
InstanceKeyType represents the different types of instance key that are supported. Usually it is sufficient to simply type-assert an InstanceKey value to either IntKey or StringKey, but this type and its values can be used to represent the types themselves, rather than specific values of those types.
const ( NoKeyType InstanceKeyType = 0 IntKeyType InstanceKeyType = 'I' StringKeyType InstanceKeyType = 'S' )
type IntKey ¶
type IntKey int
IntKey is the InstanceKey representation representing integer indices, as used when the "count" argument is specified or if for_each is used with a sequence type.
type LocalValue ¶
type LocalValue struct { Name string // contains filtered or unexported fields }
LocalValue is the address of a local value.
func (LocalValue) Absolute ¶
func (v LocalValue) Absolute(m ModuleInstance) AbsLocalValue
Absolute converts the receiver into an absolute address within the given module instance.
func (LocalValue) String ¶
func (v LocalValue) String() string
type Module ¶
type Module []string
Module is an address for a module call within configuration. This is the static counterpart of ModuleInstance, representing a traversal through the static module call tree in configuration and does not take into account the potentially-multiple instances of a module that might be created by "count" and "for_each" arguments within those calls.
This type should be used only in very specialized cases when working with the static module call tree. Type ModuleInstance is appropriate in more cases.
Although Module is a slice, it should be treated as immutable after creation.
var RootModule Module
RootModule is the module address representing the root of the static module call tree, which is also the zero value of Module.
Note that this is not the root of the dynamic module tree, which is instead represented by RootModuleInstance.
func (Module) Call ¶
func (m Module) Call() (Module, ModuleCall)
Call returns the module call address that corresponds to the given module instance, along with the address of the module that contains it.
There is no call for the root module, so this method will panic if called on the root module address.
In practice, this just turns the last element of the receiver into a ModuleCall and then returns a slice of the receiever that excludes that last part. This is just a convenience for situations where a call address is required, such as when dealing with *Reference and Referencable values.
func (Module) Child ¶
Child returns the address of a child call in the receiver, identified by the given name.
func (Module) IsRoot ¶
IsRoot returns true if the receiver is the address of the root module, or false otherwise.
func (Module) Parent ¶
Parent returns the address of the parent module of the receiver, or the receiver itself if there is no parent (if it's the root module address).
func (Module) UnkeyedInstanceShim ¶
func (m Module) UnkeyedInstanceShim() ModuleInstance
UnkeyedInstanceShim is a shim method for converting a Module address to the equivalent ModuleInstance address that assumes that no modules have keyed instances.
This is a temporary allowance for the fact that Terraform does not presently support "count" and "for_each" on modules, and thus graph building code that derives graph nodes from configuration must just assume unkeyed modules in order to construct the graph. At a later time when "count" and "for_each" support is added for modules, all callers of this method will need to be reworked to allow for keyed module instances.
type ModuleCall ¶
type ModuleCall struct { Name string // contains filtered or unexported fields }
ModuleCall is the address of a call from the current module to a child module.
There is no "Abs" version of ModuleCall because an absolute module path is represented by ModuleInstance.
func (ModuleCall) Instance ¶
func (c ModuleCall) Instance(key InstanceKey) ModuleCallInstance
Instance returns the address of an instance of the receiver identified by the given key.
func (ModuleCall) String ¶
func (c ModuleCall) String() string
type ModuleCallInstance ¶
type ModuleCallInstance struct { Call ModuleCall Key InstanceKey // contains filtered or unexported fields }
ModuleCallInstance is the address of one instance of a module created from a module call, which might create multiple instances using "count" or "for_each" arguments.
func (ModuleCallInstance) ModuleInstance ¶
func (c ModuleCallInstance) ModuleInstance(caller ModuleInstance) ModuleInstance
ModuleInstance returns the address of the module instance that corresponds to the receiving call instance when resolved in the given calling module. In other words, it returns the child module instance that the receving call instance creates.
func (ModuleCallInstance) Output ¶
func (c ModuleCallInstance) Output(name string) ModuleCallOutput
Output returns the address of an output of the receiver identified by its name.
func (ModuleCallInstance) String ¶
func (c ModuleCallInstance) String() string
type ModuleCallOutput ¶
type ModuleCallOutput struct { Call ModuleCallInstance Name string // contains filtered or unexported fields }
ModuleCallOutput is the address of a particular named output produced by an instance of a module call.
func (ModuleCallOutput) AbsOutputValue ¶
func (co ModuleCallOutput) AbsOutputValue(caller ModuleInstance) AbsOutputValue
AbsOutputValue returns the absolute output value address that corresponds to the receving module call output address, once resolved in the given calling module.
func (ModuleCallOutput) String ¶
func (co ModuleCallOutput) String() string
type ModuleInstance ¶
type ModuleInstance []ModuleInstanceStep
ModuleInstance is an address for a particular module instance within the dynamic module tree. This is an extension of the static traversals represented by type Module that deals with the possibility of a single module call producing multiple instances via the "count" and "for_each" arguments.
Although ModuleInstance is a slice, it should be treated as immutable after creation.
var RootModuleInstance ModuleInstance
RootModuleInstance is the module instance address representing the root module, which is also the zero value of ModuleInstance.
func ParseModuleInstance ¶
func ParseModuleInstance(traversal hcl.Traversal) (ModuleInstance, tfdiags.Diagnostics)
func ParseModuleInstanceStr ¶
func ParseModuleInstanceStr(str string) (ModuleInstance, tfdiags.Diagnostics)
ParseModuleInstanceStr is a helper wrapper around ParseModuleInstance that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
This should be used only in specialized situations since it will cause the created references to not have any meaningful source location information. If a reference string is coming from a source that should be identified in error messages then the caller should instead parse it directly using a suitable function from the HCL API and pass the traversal itself to ParseProviderConfigCompact.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned then the returned address is invalid.
func (ModuleInstance) Ancestors ¶
func (m ModuleInstance) Ancestors() []ModuleInstance
Ancestors returns a slice containing the receiver and all of its ancestor module instances, all the way up to (and including) the root module. The result is ordered by depth, with the root module always first.
Since the result always includes the root module, a caller may choose to ignore it by slicing the result with [1:].
func (ModuleInstance) Call ¶
func (m ModuleInstance) Call() (ModuleInstance, ModuleCall)
Call returns the module call address that corresponds to the given module instance, along with the address of the module instance that contains it.
There is no call for the root module, so this method will panic if called on the root module address.
A single module call can produce potentially many module instances, so the result discards any instance key that might be present on the last step of the instance. To retain this, use CallInstance instead.
In practice, this just turns the last element of the receiver into a ModuleCall and then returns a slice of the receiever that excludes that last part. This is just a convenience for situations where a call address is required, such as when dealing with *Reference and Referencable values.
func (ModuleInstance) CallInstance ¶
func (m ModuleInstance) CallInstance() (ModuleInstance, ModuleCallInstance)
CallInstance returns the module call instance address that corresponds to the given module instance, along with the address of the module instance that contains it.
There is no call for the root module, so this method will panic if called on the root module address.
In practice, this just turns the last element of the receiver into a ModuleCallInstance and then returns a slice of the receiever that excludes that last part. This is just a convenience for situations where a call\ address is required, such as when dealing with *Reference and Referencable values.
func (ModuleInstance) Child ¶
func (m ModuleInstance) Child(name string, key InstanceKey) ModuleInstance
Child returns the address of a child module instance of the receiver, identified by the given name and key.
func (ModuleInstance) Equal ¶
func (m ModuleInstance) Equal(o ModuleInstance) bool
Equal returns true if the receiver and the given other value contains the exact same parts.
func (ModuleInstance) InputVariable ¶
func (m ModuleInstance) InputVariable(name string) AbsInputVariableInstance
InputVariable returns the absolute address of the input variable of the given name inside the receiving module instance.
func (ModuleInstance) IsAncestor ¶
func (m ModuleInstance) IsAncestor(o ModuleInstance) bool
IsAncestor returns true if the receiver is an ancestor of the given other value.
func (ModuleInstance) IsRoot ¶
func (m ModuleInstance) IsRoot() bool
IsRoot returns true if the receiver is the address of the root module instance, or false otherwise.
func (ModuleInstance) Less ¶
func (m ModuleInstance) Less(o ModuleInstance) bool
Less returns true if the receiver should sort before the given other value in a sorted list of addresses.
func (ModuleInstance) LocalValue ¶
func (m ModuleInstance) LocalValue(name string) AbsLocalValue
LocalValue returns the absolute address of a local value of the given name within the receiving module instance.
func (ModuleInstance) OutputValue ¶
func (m ModuleInstance) OutputValue(name string) AbsOutputValue
OutputValue returns the absolute address of an output value of the given name within the receiving module instance.
func (ModuleInstance) Parent ¶
func (m ModuleInstance) Parent() ModuleInstance
Parent returns the address of the parent module instance of the receiver, or the receiver itself if there is no parent (if it's the root module address).
func (ModuleInstance) ProviderConfigAliased ¶
func (m ModuleInstance) ProviderConfigAliased(name, alias string) AbsProviderConfig
ProviderConfigAliased returns the address of an aliased provider config of with given type and alias inside the recieving module instance.
func (ModuleInstance) ProviderConfigDefault ¶
func (m ModuleInstance) ProviderConfigDefault(name string) AbsProviderConfig
ProviderConfigDefault returns the address of the default provider config of the given type inside the recieving module instance.
func (ModuleInstance) Resource ¶
func (m ModuleInstance) Resource(mode ResourceMode, typeName string, name string) AbsResource
Resource returns the address of a particular resource within the receiver.
func (ModuleInstance) ResourceInstance ¶
func (m ModuleInstance) ResourceInstance(mode ResourceMode, typeName string, name string, key InstanceKey) AbsResourceInstance
ResourceInstance returns the address of a particular resource instance within the receiver.
func (ModuleInstance) String ¶
func (m ModuleInstance) String() string
String returns a string representation of the receiver, in the format used within e.g. user-provided resource addresses.
The address of the root module has the empty string as its representation.
func (ModuleInstance) TargetContains ¶
func (m ModuleInstance) TargetContains(other Targetable) bool
TargetContains implements Targetable by returning true if the given other address either matches the receiver, is a sub-module-instance of the receiver, or is a targetable absolute address within a module that is contained within the reciever.
type ModuleInstanceStep ¶
type ModuleInstanceStep struct { Name string InstanceKey InstanceKey }
ModuleInstanceStep is a single traversal step through the dynamic module tree. It is used only as part of ModuleInstance.
type OutputValue ¶
type OutputValue struct {
Name string
}
OutputValue is the address of an output value, in the context of the module that is defining it.
This is related to but separate from ModuleCallOutput, which represents a module output from the perspective of its parent module. Since output values cannot be represented from the module where they are defined, OutputValue is not Referenceable, while ModuleCallOutput is.
func (OutputValue) Absolute ¶
func (v OutputValue) Absolute(m ModuleInstance) AbsOutputValue
Absolute converts the receiver into an absolute address within the given module instance.
func (OutputValue) String ¶
func (v OutputValue) String() string
type PathAttr ¶
type PathAttr struct { Name string // contains filtered or unexported fields }
PathAttr is the address of an attribute of the "path" object in the interpolation scope, like "path.module".
type ProviderConfig ¶
type ProviderConfig struct { Type string // If not empty, Alias identifies which non-default (aliased) provider // configuration this address refers to. Alias string }
ProviderConfig is the address of a provider configuration.
func NewDefaultProviderConfig ¶
func NewDefaultProviderConfig(typeName string) ProviderConfig
NewDefaultProviderConfig returns the address of the default (un-aliased) configuration for the provider with the given type name.
func ParseProviderConfigCompact ¶
func ParseProviderConfigCompact(traversal hcl.Traversal) (ProviderConfig, tfdiags.Diagnostics)
ParseProviderConfigCompact parses the given absolute traversal as a relative provider address in compact form. The following are examples of traversals that can be successfully parsed as compact relative provider configuration addresses:
aws aws.foo
This function will panic if given a relative traversal.
If the returned diagnostics contains errors then the result value is invalid and must not be used.
func ParseProviderConfigCompactStr ¶
func ParseProviderConfigCompactStr(str string) (ProviderConfig, tfdiags.Diagnostics)
ParseProviderConfigCompactStr is a helper wrapper around ParseProviderConfigCompact that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
This should be used only in specialized situations since it will cause the created references to not have any meaningful source location information. If a reference string is coming from a source that should be identified in error messages then the caller should instead parse it directly using a suitable function from the HCL API and pass the traversal itself to ParseProviderConfigCompact.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned then the returned address is invalid.
func (ProviderConfig) Absolute ¶
func (pc ProviderConfig) Absolute(module ModuleInstance) AbsProviderConfig
Absolute returns an AbsProviderConfig from the receiver and the given module instance address.
func (ProviderConfig) String ¶
func (pc ProviderConfig) String() string
func (ProviderConfig) StringCompact ¶
func (pc ProviderConfig) StringCompact() string
StringCompact is an alternative to String that returns the form that can be parsed by ParseProviderConfigCompact, without the "provider." prefix.
type Reference ¶
type Reference struct { Subject Referenceable SourceRange tfdiags.SourceRange Remaining hcl.Traversal }
Reference describes a reference to an address with source location information.
func ParseRef ¶
func ParseRef(traversal hcl.Traversal) (*Reference, tfdiags.Diagnostics)
ParseRef attempts to extract a referencable address from the prefix of the given traversal, which must be an absolute traversal or this function will panic.
If no error diagnostics are returned, the returned reference includes the address that was extracted, the source range it was extracted from, and any remaining relative traversal that was not consumed as part of the reference.
If error diagnostics are returned then the Reference value is invalid and must not be used.
func ParseRefStr ¶
func ParseRefStr(str string) (*Reference, tfdiags.Diagnostics)
ParseRefStr is a helper wrapper around ParseRef that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
This should be used only in specialized situations since it will cause the created references to not have any meaningful source location information. If a reference string is coming from a source that should be identified in error messages then the caller should instead parse it directly using a suitable function from the HCL API and pass the traversal itself to ParseRef.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned the returned reference may be nil or incomplete.
type Referenceable ¶
type Referenceable interface { // String produces a string representation of the address that could be // parsed as a HCL traversal and passed to ParseRef to produce an identical // result. String() string // contains filtered or unexported methods }
Referenceable is an interface implemented by all address types that can appear as references in configuration language expressions.
type Resource ¶
type Resource struct { Mode ResourceMode Type string Name string // contains filtered or unexported fields }
Resource is an address for a resource block within configuration, which contains potentially-multiple resource instances if that configuration block uses "count" or "for_each".
func (Resource) Absolute ¶
func (r Resource) Absolute(module ModuleInstance) AbsResource
Absolute returns an AbsResource from the receiver and the given module instance address.
func (Resource) DefaultProviderConfig ¶
func (r Resource) DefaultProviderConfig() ProviderConfig
DefaultProviderConfig returns the address of the provider configuration that should be used for the resource identified by the reciever if it does not have a provider configuration address explicitly set in configuration.
This method is not able to verify that such a configuration exists, nor represent the behavior of automatically inheriting certain provider configurations from parent modules. It just does a static analysis of the receiving address and returns an address to start from, relative to the same module that contains the resource.
func (Resource) Instance ¶
func (r Resource) Instance(key InstanceKey) ResourceInstance
Instance produces the address for a specific instance of the receiver that is idenfied by the given key.
func (Resource) Phase ¶
func (r Resource) Phase(rpt ResourceInstancePhaseType) ResourcePhase
Phase returns a special "phase address" for the receving instance. See the documentation of ResourceInstancePhase for the limited situations where this is intended to be used.
type ResourceInstance ¶
type ResourceInstance struct { Resource Resource Key InstanceKey // contains filtered or unexported fields }
ResourceInstance is an address for a specific instance of a resource. When a resource is defined in configuration with "count" or "for_each" it produces zero or more instances, which can be addressed using this type.
func (ResourceInstance) Absolute ¶
func (r ResourceInstance) Absolute(module ModuleInstance) AbsResourceInstance
Absolute returns an AbsResourceInstance from the receiver and the given module instance address.
func (ResourceInstance) ContainingResource ¶
func (r ResourceInstance) ContainingResource() Resource
func (ResourceInstance) Equal ¶
func (r ResourceInstance) Equal(o ResourceInstance) bool
func (ResourceInstance) Phase ¶
func (r ResourceInstance) Phase(rpt ResourceInstancePhaseType) ResourceInstancePhase
Phase returns a special "phase address" for the receving instance. See the documentation of ResourceInstancePhase for the limited situations where this is intended to be used.
func (ResourceInstance) String ¶
func (r ResourceInstance) String() string
type ResourceInstancePhase ¶
type ResourceInstancePhase struct { ResourceInstance ResourceInstance Phase ResourceInstancePhaseType // contains filtered or unexported fields }
ResourceInstancePhase is a special kind of reference used only internally during graph building to represent resource instances that are in a non-primary state.
Graph nodes can declare themselves referenceable via an instance phase or can declare that they reference an instance phase in order to accomodate secondary graph nodes dealing with, for example, destroy actions.
This special reference type cannot be accessed directly by end-users, and should never be shown in the UI.
func (ResourceInstancePhase) ContainingResource ¶
func (rp ResourceInstancePhase) ContainingResource() ResourcePhase
ContainingResource returns an address for the same phase of the resource that this instance belongs to.
func (ResourceInstancePhase) String ¶
func (rp ResourceInstancePhase) String() string
type ResourceInstancePhaseType ¶
type ResourceInstancePhaseType string
ResourceInstancePhaseType is an enumeration used with ResourceInstancePhase.
const ( // ResourceInstancePhaseDestroy represents the "destroy" phase of a // resource instance. ResourceInstancePhaseDestroy ResourceInstancePhaseType = "destroy" // ResourceInstancePhaseDestroyCBD is similar to ResourceInstancePhaseDestroy // but is used for resources that have "create_before_destroy" set, thus // requiring a different dependency ordering. ResourceInstancePhaseDestroyCBD ResourceInstancePhaseType = "destroy-cbd" )
func (ResourceInstancePhaseType) String ¶
func (rpt ResourceInstancePhaseType) String() string
type ResourceMode ¶
type ResourceMode rune
ResourceMode defines which lifecycle applies to a given resource. Each resource lifecycle has a slightly different address format.
const ( // InvalidResourceMode is the zero value of ResourceMode and is not // a valid resource mode. InvalidResourceMode ResourceMode = 0 // ManagedResourceMode indicates a managed resource, as defined by // "resource" blocks in configuration. ManagedResourceMode ResourceMode = 'M' // DataResourceMode indicates a data resource, as defined by // "data" blocks in configuration. DataResourceMode ResourceMode = 'D' )
func (ResourceMode) String ¶
func (i ResourceMode) String() string
type ResourcePhase ¶
type ResourcePhase struct { Resource Resource Phase ResourceInstancePhaseType // contains filtered or unexported fields }
ResourcePhase is a special kind of reference used only internally during graph building to represent resources that are in a non-primary state.
Graph nodes can declare themselves referenceable via a resource phase or can declare that they reference a resource phase in order to accomodate secondary graph nodes dealing with, for example, destroy actions.
Since resources (as opposed to instances) aren't actually phased, this address type is used only as an approximation during initial construction of the resource-oriented plan graph, under the assumption that resource instances with ResourceInstancePhase addresses will be created in dynamic subgraphs during the graph walk.
This special reference type cannot be accessed directly by end-users, and should never be shown in the UI.
func (ResourcePhase) String ¶
func (rp ResourcePhase) String() string
type StringKey ¶
type StringKey string
StringKey is the InstanceKey representation representing string indices, as used when the "for_each" argument is specified with a map or object type.
type Target ¶
type Target struct { Subject Targetable SourceRange tfdiags.SourceRange }
Target describes a targeted address with source location information.
func ParseTarget ¶
func ParseTarget(traversal hcl.Traversal) (*Target, tfdiags.Diagnostics)
ParseTarget attempts to interpret the given traversal as a targetable address. The given traversal must be absolute, or this function will panic.
If no error diagnostics are returned, the returned target includes the address that was extracted and the source range it was extracted from.
If error diagnostics are returned then the Target value is invalid and must not be used.
func ParseTargetStr ¶
func ParseTargetStr(str string) (*Target, tfdiags.Diagnostics)
ParseTargetStr is a helper wrapper around ParseTarget that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.
This should be used only in specialized situations since it will cause the created references to not have any meaningful source location information. If a target string is coming from a source that should be identified in error messages then the caller should instead parse it directly using a suitable function from the HCL API and pass the traversal itself to ParseTarget.
Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned the returned target may be nil or incomplete.
type Targetable ¶
type Targetable interface { // TargetContains returns true if the receiver is considered to contain // the given other address. Containment, for the purpose of targeting, // means that if a container address is targeted then all of the // addresses within it are also implicitly targeted. // // A targetable address always contains at least itself. TargetContains(other Targetable) bool // String produces a string representation of the address that could be // parsed as a HCL traversal and passed to ParseTarget to produce an // identical result. String() string // contains filtered or unexported methods }
Targetable is an interface implemented by all address types that can be used as "targets" for selecting sub-graphs of a graph.
type TerraformAttr ¶
type TerraformAttr struct { Name string // contains filtered or unexported fields }
TerraformAttr is the address of an attribute of the "terraform" object in the interpolation scope, like "terraform.workspace".
func (TerraformAttr) String ¶
func (ta TerraformAttr) String() string
Source Files ¶
- count_attr.go
- doc.go
- for_each_attr.go
- input_variable.go
- instance_key.go
- local_value.go
- module.go
- module_call.go
- module_instance.go
- output_value.go
- parse_ref.go
- parse_target.go
- path_attr.go
- provider_config.go
- referenceable.go
- resource.go
- resource_phase.go
- resourcemode_string.go
- self.go
- targetable.go
- terraform_attr.go