Documentation ¶
Index ¶
- Constants
- func Graph(opts *GraphOpts) (*depgraph.Graph, error)
- func GraphDot(g *depgraph.Graph) string
- func ProviderSatisfies(p ResourceProvider, n string) bool
- func WriteDiff(d *Diff, dst io.Writer) error
- func WritePlan(d *Plan, dst io.Writer) error
- func WriteState(d *State, dst io.Writer) error
- type Context
- type ContextOpts
- type Diff
- type DiffAttrType
- type GraphNodeResource
- type GraphNodeResourceMeta
- type GraphNodeResourceProvider
- type GraphOpts
- type Hook
- type HookAction
- type MockHook
- func (h *MockHook) PostApply(n string, s *ResourceState, e error) (HookAction, error)
- func (h *MockHook) PostDiff(n string, d *ResourceDiff) (HookAction, error)
- func (h *MockHook) PostProvision(id, provId string) (HookAction, error)
- func (h *MockHook) PostProvisionResource(id string, s *ResourceState) (HookAction, error)
- func (h *MockHook) PostRefresh(n string, s *ResourceState) (HookAction, error)
- func (h *MockHook) PreApply(n string, s *ResourceState, d *ResourceDiff) (HookAction, error)
- func (h *MockHook) PreDiff(n string, s *ResourceState) (HookAction, error)
- func (h *MockHook) PreProvision(id, provId string) (HookAction, error)
- func (h *MockHook) PreProvisionResource(id string, s *ResourceState) (HookAction, error)
- func (h *MockHook) PreRefresh(n string, s *ResourceState) (HookAction, error)
- type MockResourceProvider
- func (p *MockResourceProvider) Apply(state *ResourceState, diff *ResourceDiff) (*ResourceState, error)
- func (p *MockResourceProvider) Configure(c *ResourceConfig) error
- func (p *MockResourceProvider) Diff(state *ResourceState, desired *ResourceConfig) (*ResourceDiff, error)
- func (p *MockResourceProvider) Refresh(s *ResourceState) (*ResourceState, error)
- func (p *MockResourceProvider) Resources() []ResourceType
- func (p *MockResourceProvider) Validate(c *ResourceConfig) ([]string, []error)
- func (p *MockResourceProvider) ValidateResource(t string, c *ResourceConfig) ([]string, []error)
- type MockResourceProvisioner
- type NilHook
- func (*NilHook) PostApply(string, *ResourceState, error) (HookAction, error)
- func (*NilHook) PostDiff(string, *ResourceDiff) (HookAction, error)
- func (*NilHook) PostProvision(string, string) (HookAction, error)
- func (*NilHook) PostProvisionResource(string, *ResourceState) (HookAction, error)
- func (*NilHook) PostRefresh(string, *ResourceState) (HookAction, error)
- func (*NilHook) PreApply(string, *ResourceState, *ResourceDiff) (HookAction, error)
- func (*NilHook) PreDiff(string, *ResourceState) (HookAction, error)
- func (*NilHook) PreProvision(string, string) (HookAction, error)
- func (*NilHook) PreProvisionResource(string, *ResourceState) (HookAction, error)
- func (*NilHook) PreRefresh(string, *ResourceState) (HookAction, error)
- type Plan
- type PlanOpts
- type Resource
- type ResourceAttrDiff
- type ResourceConfig
- type ResourceDependency
- type ResourceDiff
- type ResourceProvider
- type ResourceProviderFactory
- type ResourceProvisioner
- type ResourceProvisionerConfig
- type ResourceProvisionerFactory
- type ResourceState
- type ResourceType
- type State
Constants ¶
const GraphRootNode = "root"
GraphRootNode is the name of the root node in the Terraform resource graph. This node is just a placemarker and has no associated functionality.
Variables ¶
This section is empty.
Functions ¶
func Graph ¶
Graph builds a dependency graph of all the resources for infrastructure change.
This dependency graph shows the correct order that any resources need to be operated on.
The Meta field of a graph Noun can contain one of the follow types. A description is next to each type to explain what it is.
*GraphNodeResource - A resource. See the documentation of this struct for more details. *GraphNodeResourceProvider - A resource provider that needs to be configured at this point.
func GraphDot ¶
GraphDot returns the dot formatting of a visual representation of the given Terraform graph.
func ProviderSatisfies ¶
func ProviderSatisfies(p ResourceProvider, n string) bool
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents all the context that Terraform needs in order to perform operations on infrastructure. This structure is built using ContextOpts and NewContext. See the documentation for those.
Additionally, a context can be created from a Plan using Plan.Context.
func NewContext ¶
func NewContext(opts *ContextOpts) *Context
NewContext creates a new context.
Once a context is created, the pointer values within ContextOpts should not be mutated in any way, since the pointers are copied, not the values themselves.
func (*Context) Apply ¶
Apply applies the changes represented by this context and returns the resulting state.
In addition to returning the resulting state, this context is updated with the latest state.
func (*Context) Plan ¶
Plan generates an execution plan for the given context.
The execution plan encapsulates the context and can be stored in order to reinstantiate a context later for Apply.
Plan also updates the diff of this context to be the diff generated by the plan, so Apply can be called after.
func (*Context) Refresh ¶
Refresh goes through all the resources in the state and refreshes them to their latest state. This will update the state that this context works with, along with returning it.
Even in the case an error is returned, the state will be returned and will potentially be partially updated.
type ContextOpts ¶
type ContextOpts struct { Config *config.Config Diff *Diff Hooks []Hook Parallelism int State *State Providers map[string]ResourceProviderFactory Provisioners map[string]ResourceProvisionerFactory Variables map[string]string }
ContextOpts are the user-creatable configuration structure to create a context with NewContext.
type Diff ¶
type Diff struct { Resources map[string]*ResourceDiff // contains filtered or unexported fields }
Diff tracks the differences between resources to apply.
type DiffAttrType ¶
type DiffAttrType byte
DiffAttrType is an enum type that says whether a resource attribute diff is an input attribute (comes from the configuration) or an output attribute (comes as a result of applying the configuration). An example input would be "ami" for AWS and an example output would be "private_ip".
const ( DiffAttrUnknown DiffAttrType = iota DiffAttrInput DiffAttrOutput )
type GraphNodeResource ¶
type GraphNodeResource struct { Index int Type string Config *config.Resource Orphan bool Resource *Resource ResourceProviderID string }
GraphNodeResource is a node type in the graph that represents a resource that will be created or managed. Unlike the GraphNodeResourceMeta node, this represents a _single_, _resource_ to be managed, not a set of resources or a component of a resource.
type GraphNodeResourceMeta ¶
GraphNodeResourceMeta is a node type in the graph that represents the metadata for a resource. There will be one meta node for every resource in the configuration.
type GraphNodeResourceProvider ¶
type GraphNodeResourceProvider struct { ID string Providers map[string]ResourceProvider ProviderKeys []string Config *config.ProviderConfig }
GraphNodeResourceProvider is a node type in the graph that represents the configuration for a resource provider.
type GraphOpts ¶
type GraphOpts struct { // Config is the configuration from which to build the basic graph. // This is the only required item. Config *config.Config // Diff of changes that will be applied to the given state. This will // associate a ResourceDiff with applicable resources. Additionally, // new resource nodes representing resource destruction may be inserted // into the graph. Diff *Diff // State, if present, will make the ResourceState available on each // resource node. Additionally, any orphans will be added automatically // to the graph. State *State // Providers is a mapping of prefixes to a resource provider. If given, // resource providers will be found, initialized, and associated to the // resources in the graph. // // This will also potentially insert new nodes into the graph for // the configuration of resource providers. Providers map[string]ResourceProviderFactory // Provisioners is a mapping of names to a resource provisioner. // These must be provided to support resource provisioners. Provisioners map[string]ResourceProvisionerFactory }
GraphOpts are options used to create the resource graph that Terraform walks to make changes to infrastructure.
Depending on what options are set, the resulting graph will come in varying degrees of completeness.
type Hook ¶
type Hook interface { // PreApply and PostApply are called before and after a single // resource is applied. The error argument in PostApply is the // error, if any, that was returned from the provider Apply call itself. PreApply(string, *ResourceState, *ResourceDiff) (HookAction, error) PostApply(string, *ResourceState, error) (HookAction, error) // PreDiff and PostDiff are called before and after a single resource // resource is diffed. PreDiff(string, *ResourceState) (HookAction, error) PostDiff(string, *ResourceDiff) (HookAction, error) // Provisioning hooks PreProvisionResource(string, *ResourceState) (HookAction, error) PostProvisionResource(string, *ResourceState) (HookAction, error) PreProvision(string, string) (HookAction, error) PostProvision(string, string) (HookAction, error) // PreRefresh and PostRefresh are called before and after a single // resource state is refreshed, respectively. PreRefresh(string, *ResourceState) (HookAction, error) PostRefresh(string, *ResourceState) (HookAction, error) }
Hook is the interface that must be implemented to hook into various parts of Terraform, allowing you to inspect or change behavior at runtime.
There are MANY hook points into Terraform. If you only want to implement some hook points, but not all (which is the likely case), then embed the NilHook into your struct, which implements all of the interface but does nothing. Then, override only the functions you want to implement.
type HookAction ¶
type HookAction byte
HookAction is an enum of actions that can be taken as a result of a hook callback. This allows you to modify the behavior of Terraform at runtime.
const ( // HookActionContinue continues with processing as usual. HookActionContinue HookAction = iota // HookActionHalt halts immediately: no more hooks are processed // and the action that Terraform was about to take is cancelled. HookActionHalt )
type MockHook ¶
type MockHook struct { PreApplyCalled bool PreApplyId string PreApplyDiff *ResourceDiff PreApplyState *ResourceState PreApplyReturn HookAction PreApplyError error PostApplyCalled bool PostApplyId string PostApplyState *ResourceState PostApplyError error PostApplyReturn HookAction PostApplyReturnError error PreDiffCalled bool PreDiffId string PreDiffState *ResourceState PreDiffReturn HookAction PreDiffError error PostDiffCalled bool PostDiffId string PostDiffDiff *ResourceDiff PostDiffReturn HookAction PostDiffError error PreProvisionResourceCalled bool PreProvisionResourceId string PreProvisionResourceState *ResourceState PreProvisionResourceReturn HookAction PreProvisionResourceError error PostProvisionResourceCalled bool PostProvisionResourceId string PostProvisionResourceState *ResourceState PostProvisionResourceReturn HookAction PostProvisionResourceError error PreProvisionCalled bool PreProvisionId string PreProvisionProvisionerId string PreProvisionReturn HookAction PreProvisionError error PostProvisionCalled bool PostProvisionId string PostProvisionProvisionerId string PostProvisionReturn HookAction PostProvisionError error PostRefreshCalled bool PostRefreshId string PostRefreshState *ResourceState PostRefreshReturn HookAction PostRefreshError error PreRefreshCalled bool PreRefreshId string PreRefreshState *ResourceState PreRefreshReturn HookAction PreRefreshError error }
MockHook is an implementation of Hook that can be used for tests. It records all of its function calls.
func (*MockHook) PostApply ¶
func (h *MockHook) PostApply(n string, s *ResourceState, e error) (HookAction, error)
func (*MockHook) PostDiff ¶
func (h *MockHook) PostDiff(n string, d *ResourceDiff) (HookAction, error)
func (*MockHook) PostProvision ¶
func (h *MockHook) PostProvision(id, provId string) (HookAction, error)
func (*MockHook) PostProvisionResource ¶
func (h *MockHook) PostProvisionResource(id string, s *ResourceState) (HookAction, error)
func (*MockHook) PostRefresh ¶
func (h *MockHook) PostRefresh(n string, s *ResourceState) (HookAction, error)
func (*MockHook) PreApply ¶
func (h *MockHook) PreApply(n string, s *ResourceState, d *ResourceDiff) (HookAction, error)
func (*MockHook) PreDiff ¶
func (h *MockHook) PreDiff(n string, s *ResourceState) (HookAction, error)
func (*MockHook) PreProvision ¶
func (h *MockHook) PreProvision(id, provId string) (HookAction, error)
func (*MockHook) PreProvisionResource ¶
func (h *MockHook) PreProvisionResource(id string, s *ResourceState) (HookAction, error)
func (*MockHook) PreRefresh ¶
func (h *MockHook) PreRefresh(n string, s *ResourceState) (HookAction, error)
type MockResourceProvider ¶
type MockResourceProvider struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. Meta interface{} ApplyCalled bool ApplyState *ResourceState ApplyDiff *ResourceDiff ApplyFn func(*ResourceState, *ResourceDiff) (*ResourceState, error) ApplyReturn *ResourceState ApplyReturnError error ConfigureCalled bool ConfigureConfig *ResourceConfig ConfigureReturnError error DiffCalled bool DiffState *ResourceState DiffDesired *ResourceConfig DiffFn func(*ResourceState, *ResourceConfig) (*ResourceDiff, error) DiffReturn *ResourceDiff DiffReturnError error RefreshCalled bool RefreshState *ResourceState RefreshFn func(*ResourceState) (*ResourceState, error) RefreshReturn *ResourceState RefreshReturnError error ResourcesCalled bool ResourcesReturn []ResourceType ValidateCalled bool ValidateConfig *ResourceConfig ValidateReturnWarns []string ValidateReturnErrors []error ValidateResourceFn func(string, *ResourceConfig) ([]string, []error) ValidateResourceCalled bool ValidateResourceType string ValidateResourceConfig *ResourceConfig ValidateResourceReturnWarns []string ValidateResourceReturnErrors []error }
MockResourceProvider implements ResourceProvider but mocks out all the calls for testing purposes.
func (*MockResourceProvider) Apply ¶
func (p *MockResourceProvider) Apply( state *ResourceState, diff *ResourceDiff) (*ResourceState, error)
func (*MockResourceProvider) Configure ¶
func (p *MockResourceProvider) Configure(c *ResourceConfig) error
func (*MockResourceProvider) Diff ¶
func (p *MockResourceProvider) Diff( state *ResourceState, desired *ResourceConfig) (*ResourceDiff, error)
func (*MockResourceProvider) Refresh ¶
func (p *MockResourceProvider) Refresh( s *ResourceState) (*ResourceState, error)
func (*MockResourceProvider) Resources ¶
func (p *MockResourceProvider) Resources() []ResourceType
func (*MockResourceProvider) Validate ¶
func (p *MockResourceProvider) Validate(c *ResourceConfig) ([]string, []error)
func (*MockResourceProvider) ValidateResource ¶
func (p *MockResourceProvider) ValidateResource(t string, c *ResourceConfig) ([]string, []error)
type MockResourceProvisioner ¶
type MockResourceProvisioner struct { // Anything you want, in case you need to store extra data with the mock. Meta interface{} ApplyCalled bool ApplyState *ResourceState ApplyConfig *ResourceConfig ApplyFn func(*ResourceState, *ResourceConfig) error ApplyReturnError error ValidateCalled bool ValidateConfig *ResourceConfig ValidateFn func(c *ResourceConfig) ([]string, []error) ValidateReturnWarns []string ValidateReturnErrors []error }
MockResourceProvisioner implements ResourceProvisioner but mocks out all the calls for testing purposes.
func (*MockResourceProvisioner) Apply ¶
func (p *MockResourceProvisioner) Apply(state *ResourceState, c *ResourceConfig) error
func (*MockResourceProvisioner) Validate ¶
func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error)
type NilHook ¶
type NilHook struct{}
NilHook is a Hook implementation that does nothing. It exists only to simplify implementing hooks. You can embed this into your Hook implementation and only implement the functions you are interested in.
func (*NilHook) PostApply ¶
func (*NilHook) PostApply(string, *ResourceState, error) (HookAction, error)
func (*NilHook) PostDiff ¶
func (*NilHook) PostDiff(string, *ResourceDiff) (HookAction, error)
func (*NilHook) PostProvision ¶
func (*NilHook) PostProvision(string, string) (HookAction, error)
func (*NilHook) PostProvisionResource ¶
func (*NilHook) PostProvisionResource(string, *ResourceState) (HookAction, error)
func (*NilHook) PostRefresh ¶
func (*NilHook) PostRefresh(string, *ResourceState) (HookAction, error)
func (*NilHook) PreApply ¶
func (*NilHook) PreApply(string, *ResourceState, *ResourceDiff) (HookAction, error)
func (*NilHook) PreDiff ¶
func (*NilHook) PreDiff(string, *ResourceState) (HookAction, error)
func (*NilHook) PreProvision ¶
func (*NilHook) PreProvision(string, string) (HookAction, error)
func (*NilHook) PreProvisionResource ¶
func (*NilHook) PreProvisionResource(string, *ResourceState) (HookAction, error)
func (*NilHook) PreRefresh ¶
func (*NilHook) PreRefresh(string, *ResourceState) (HookAction, error)
type Plan ¶
type Plan struct { Config *config.Config Diff *Diff State *State Vars map[string]string // contains filtered or unexported fields }
Plan represents a single Terraform execution plan, which contains all the information necessary to make an infrastructure change.
func ReadPlan ¶
ReadPlan reads a plan structure out of a reader in the format that was written by WritePlan.
func (*Plan) Context ¶
func (p *Plan) Context(opts *ContextOpts) *Context
Context returns a Context with the data encapsulated in this plan.
The following fields in opts are overridden by the plan: Config, Diff, State, Variables.
type PlanOpts ¶
type PlanOpts struct { // If set to true, then the generated plan will destroy all resources // that are created. Otherwise, it will move towards the desired state // specified in the configuration. Destroy bool }
PlanOpts are the options used to generate an execution plan for Terraform.
type Resource ¶
type Resource struct { Id string Config *ResourceConfig Diff *ResourceDiff Provider ResourceProvider State *ResourceState Provisioners []*ResourceProvisionerConfig Tainted bool }
Resource encapsulates a resource, its configuration, its provider, its current state, and potentially a desired diff from the state it wants to reach.
type ResourceAttrDiff ¶
type ResourceAttrDiff struct { Old string // Old Value New string // New Value NewComputed bool // True if new value is computed (unknown currently) NewRemoved bool // True if this attribute is being removed NewExtra interface{} // Extra information for the provider RequiresNew bool // True if change requires new resource Type DiffAttrType }
ResourceAttrDiff is the diff of a single attribute of a resource.
func (*ResourceAttrDiff) GoString ¶
func (d *ResourceAttrDiff) GoString() string
type ResourceConfig ¶
type ResourceConfig struct { ComputedKeys []string Raw map[string]interface{} Config map[string]interface{} // contains filtered or unexported fields }
ResourceConfig holds the configuration given for a resource. This is done instead of a raw `map[string]interface{}` type so that rich methods can be added to it to make dealing with it easier.
func NewResourceConfig ¶
func NewResourceConfig(c *config.RawConfig) *ResourceConfig
NewResourceConfig creates a new ResourceConfig from a config.RawConfig.
func (*ResourceConfig) CheckSet ¶
func (c *ResourceConfig) CheckSet(keys []string) []error
CheckSet checks that the given list of configuration keys is properly set. If not, errors are returned for each unset key.
This is useful to be called in the Validate method of a ResourceProvider.
func (*ResourceConfig) Get ¶
func (c *ResourceConfig) Get(k string) (interface{}, bool)
Get looks up a configuration value by key and returns the value.
The second return value is true if the get was successful. Get will not succeed if the value is being computed.
func (*ResourceConfig) IsSet ¶
func (c *ResourceConfig) IsSet(k string) bool
IsSet checks if the key in the configuration is set. A key is set if it has a value or the value is being computed (is unknown currently).
This function should be used rather than checking the keys of the raw configuration itself, since a key may be omitted from the raw configuration if it is being computed.
type ResourceDependency ¶
type ResourceDependency struct { // ID of the resource that we depend on. This ID should map // directly to another ResourceState's ID. ID string }
ResourceDependency maps a resource to another resource that it depends on to remain intact and uncorrupted.
type ResourceDiff ¶
type ResourceDiff struct { Attributes map[string]*ResourceAttrDiff Destroy bool // contains filtered or unexported fields }
ResourceDiff is the diff of a resource from some state to another.
func (*ResourceDiff) Empty ¶
func (d *ResourceDiff) Empty() bool
Empty returns true if this diff encapsulates no changes.
func (*ResourceDiff) RequiresNew ¶
func (d *ResourceDiff) RequiresNew() bool
RequiresNew returns true if the diff requires the creation of a new resource (implying the destruction of the old).
func (*ResourceDiff) Same ¶
func (d *ResourceDiff) Same(d2 *ResourceDiff) bool
Same checks whether or not to ResourceDiffs are the "same." When we say "same", it is not necessarily exactly equal. Instead, it is just checking that the same attributes are changing, a destroy isn't suddenly happening, etc.
type ResourceProvider ¶
type ResourceProvider interface { // Validate is called once at the beginning with the raw configuration // (no interpolation done) and can return a list of warnings and/or // errors. // // This is called once with the provider configuration only. It may not // be called at all if no provider configuration is given. // // This should not assume that any values of the configurations are valid. // The primary use case of this call is to check that required keys are // set. Validate(*ResourceConfig) ([]string, []error) // ValidateResource is called once at the beginning with the raw // configuration (no interpolation done) and can return a list of warnings // and/or errors. // // This is called once per resource. // // This should not assume any of the values in the resource configuration // are valid since it is possible they have to be interpolated still. // The primary use case of this call is to check that the required keys // are set and that the general structure is correct. ValidateResource(string, *ResourceConfig) ([]string, []error) // Configure configures the provider itself with the configuration // given. This is useful for setting things like access keys. // // This won't be called at all if no provider configuration is given. // // Configure returns an error if it occurred. Configure(*ResourceConfig) error // Resources returns all the available resource types that this provider // knows how to manage. Resources() []ResourceType // Apply applies a diff to a specific resource and returns the new // resource state along with an error. // // If the resource state given has an empty ID, then a new resource // is expected to be created. Apply( *ResourceState, *ResourceDiff) (*ResourceState, error) // Diff diffs a resource versus a desired state and returns // a diff. Diff( *ResourceState, *ResourceConfig) (*ResourceDiff, error) // Refresh refreshes a resource and updates all of its attributes // with the latest information. Refresh(*ResourceState) (*ResourceState, error) }
ResourceProvider is an interface that must be implemented by any resource provider: the thing that creates and manages the resources in a Terraform configuration.
type ResourceProviderFactory ¶
type ResourceProviderFactory func() (ResourceProvider, error)
ResourceProviderFactory is a function type that creates a new instance of a resource provider.
func ResourceProviderFactoryFixed ¶
func ResourceProviderFactoryFixed(p ResourceProvider) ResourceProviderFactory
ResourceProviderFactoryFixed is a helper that creates a ResourceProviderFactory that just returns some fixed provider.
type ResourceProvisioner ¶
type ResourceProvisioner interface { // Validate is called once at the beginning with the raw // configuration (no interpolation done) and can return a list of warnings // and/or errors. // // This is called once per resource. // // This should not assume any of the values in the resource configuration // are valid since it is possible they have to be interpolated still. // The primary use case of this call is to check that the required keys // are set and that the general structure is correct. Validate(*ResourceConfig) ([]string, []error) // Apply runs the provisioner on a specific resource and returns the new // resource state along with an error. Instead of a diff, the ResourceConfig // is provided since provisioners only run after a resource has been // newly created. Apply(*ResourceState, *ResourceConfig) error }
ResourceProvisioner is an interface that must be implemented by any resource provisioner: the thing that initializes resources in a Terraform configuration.
type ResourceProvisionerConfig ¶
type ResourceProvisionerConfig struct { Type string Provisioner ResourceProvisioner Config *ResourceConfig RawConfig *config.RawConfig ConnInfo *config.RawConfig }
ResourceProvisionerConfig is used to pair a provisioner with its provided configuration. This allows us to use singleton instances of each ResourceProvisioner and to keep the relevant configuration instead of instantiating a new Provisioner for each resource.
type ResourceProvisionerFactory ¶
type ResourceProvisionerFactory func() (ResourceProvisioner, error)
ResourceProvisionerFactory is a function type that creates a new instance of a resource provisioner.
type ResourceState ¶
type ResourceState struct { // This is filled in and managed by Terraform, and is the resource // type itself such as "mycloud_instance". If a resource provider sets // this value, it won't be persisted. Type string // A unique ID for this resource. This is opaque to Terraform // and is only meant as a lookup mechanism for the providers. ID string // Attributes are basic information about the resource. Any keys here // are accessible in variable format within Terraform configurations: // ${resourcetype.name.attribute}. Attributes map[string]string // ConnInfo is used for the providers to export information which is // used to connect to the resource for provisioning. For example, // this could contain SSH or WinRM credentials. ConnInfo map[string]string // Extra information that the provider can store about a resource. // This data is opaque, never shown to the user, and is sent back to // the provider as-is for whatever purpose appropriate. Extra map[string]interface{} // Dependencies are a list of things that this resource relies on // existing to remain intact. For example: an AWS instance might // depend on a subnet (which itself might depend on a VPC, and so // on). // // Terraform uses this information to build valid destruction // orders and to warn the user if they're destroying a resource that // another resource depends on. // // Things can be put into this list that may not be managed by // Terraform. If Terraform doesn't find a matching ID in the // overall state, then it assumes it isn't managed and doesn't // worry about it. Dependencies []ResourceDependency }
ResourceState holds the state of a resource that is used so that a provider can find and manage an existing resource as well as for storing attributes that are uesd to populate variables of child resources.
Attributes has attributes about the created resource that are queryable in interpolation: "${type.id.attr}"
Extra is just extra data that a provider can return that we store for later, but is not exposed in any way to the user.
func (*ResourceState) GoString ¶
func (s *ResourceState) GoString() string
func (*ResourceState) MergeDiff ¶
func (s *ResourceState) MergeDiff(d *ResourceDiff) *ResourceState
MergeDiff takes a ResourceDiff and merges the attributes into this resource state in order to generate a new state. This new state can be used to provide updated attribute lookups for variable interpolation.
If the diff attribute requires computing the value, and hence won't be available until apply, the value is replaced with the computeID.
type ResourceType ¶
type ResourceType struct {
Name string
}
ResourceType is a type of resource that a resource provider can manage.
type State ¶
type State struct { Outputs map[string]string Resources map[string]*ResourceState Tainted map[string]struct{} // contains filtered or unexported fields }
State keeps track of a snapshot state-of-the-world that Terraform can use to keep track of what real world resources it is actually managing.
func ReadState ¶
ReadState reads a state structure out of a reader in the format that was written by WriteState.