@@ -23,7 +23,7 @@ in more detail in a corresponding section below.
2323Each time a user runs the ` terraform ` program, aside from some initial
2424bootstrapping in the root package (not shown in the diagram) execution
2525transfers immediately into one of the "command" implementations in
26- [ the ` command ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/command ) .
26+ [ the ` command ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ command ) .
2727The mapping between the user-facing command names and
2828their corresponding ` command ` package types can be found in the ` commands.go `
2929file in the root of the repository.
@@ -35,7 +35,7 @@ but it applies to the main Terraform workflow commands `terraform plan` and
3535For these commands, the role of the command implementation is to read and parse
3636any command line arguments, command line options, and environment variables
3737that are needed for the given command and use them to produce a
38- [ ` backend.Operation ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/backend#Operation )
38+ [ ` backend.Operation ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ backend#Operation )
3939object that describes an action to be taken.
4040
4141An _ operation_ consists of:
@@ -52,18 +52,18 @@ An _operation_ consists of:
5252The operation is then passed to the currently-selected
5353[ backend] ( https://www.terraform.io/docs/backends/index.html ) . Each backend name
5454corresponds to an implementation of
55- [ ` backend.Backend ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/backend#Backend ) , using a
55+ [ ` backend.Backend ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ backend#Backend ) , using a
5656mapping table in
57- [ the ` backend/init ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/backend/init ) .
57+ [ the ` backend/init ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ backend/init ) .
5858
5959Backends that are able to execute operations additionally implement
60- [ ` backend.Enhanced ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/backend#Enhanced ) ;
60+ [ ` backend.Enhanced ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ backend#Enhanced ) ;
6161the command-handling code calls ` Operation ` with the operation it has
6262constructed, and then the backend is responsible for executing that action.
6363
6464Most backends do _ not_ implement this interface, and so the ` command ` package
6565wraps these backends in an instance of
66- [ ` local.Local ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/backend/local#Local ) ,
66+ [ ` local.Local ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ backend/local#Local ) ,
6767causing the operation to be executed locally within the ` terraform ` process
6868itself, which (at the time of writing) is currently the only way an operation
6969can be executed.
@@ -85,41 +85,41 @@ elsewhere.
8585
8686To execute an operation locally, the ` local ` backend uses a _ state manager_
8787(either
88- [ ` statemgr.Filesystem ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/states/statemgr#Filesystem ) if the
88+ [ ` statemgr.Filesystem ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ states/statemgr#Filesystem ) if the
8989local backend is being used directly, or an implementation provided by whatever
9090backend is being wrapped) to retrieve the current state for the workspace
9191specified in the operation, then uses the _ config loader_ to load and do
9292initial processing/validation of the configuration specified in the
9393operation. It then uses these, along with the other settings given in the
9494operation, to construct a
95- [ ` terraform.Context ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#Context ) ,
95+ [ ` terraform.Context ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#Context ) ,
9696which is the main object that actually performs Terraform operations.
9797
9898The ` local ` backend finally calls an appropriate method on that context to
9999begin execution of the relevant command, such as
100- [ ` Plan ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#Context.Plan )
100+ [ ` Plan ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#Context.Plan )
101101or
102102[ ` Apply ` ] ( ) , which in turn constructs a graph using a _ graph builder_ ,
103103described in a later section.
104104
105105## Configuration Loader
106106
107107The top-level configuration structure is represented by model types in
108- [ package ` configs ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/configs ) .
108+ [ package ` configs ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ configs ) .
109109A whole configuration (the root module plus all of its descendent modules)
110110is represented by
111- [ ` configs.Config ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/configs#Config ) .
111+ [ ` configs.Config ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ configs#Config ) .
112112
113113The ` configs ` package contains some low-level functionality for constructing
114114configuration objects, but the main entry point is in the sub-package
115- [ ` configload ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/configs/configload] ) ,
115+ [ ` configload ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ configs/configload] ) ,
116116via
117- [ ` configload.Loader ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/configs/configload#Loader ) .
117+ [ ` configload.Loader ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ configs/configload#Loader ) .
118118A loader deals with all of the details of installing child modules
119119(during ` terraform init ` ) and then locating those modules again when a
120120configuration is loaded by a backend. It takes the path to a root module
121121and recursively loads all of the child modules to produce a single
122- [ ` configs.Config ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/configs#Config )
122+ [ ` configs.Config ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ configs#Config )
123123representing the entire configuration.
124124
125125Terraform expects configuration files written in the Terraform language, which
@@ -139,17 +139,17 @@ A _state manager_ is responsible for storing and retrieving snapshots of the
139139[ Terraform state] ( https://www.terraform.io/docs/language/state/index.html )
140140for a particular workspace. Each manager is an implementation of
141141some combination of interfaces in
142- [ the ` statemgr ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/states/statemgr ) ,
142+ [ the ` statemgr ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ states/statemgr ) ,
143143with most practical managers implementing the full set of operations
144144described by
145- [ ` statemgr.Full ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/states/statemgr#Full )
145+ [ ` statemgr.Full ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ states/statemgr#Full )
146146provided by a _ backend_ . The smaller interfaces exist primarily for use in
147147other function signatures to be explicit about what actions the function might
148148take on the state manager; there is little reason to write a state manager
149149that does not implement all of ` statemgr.Full ` .
150150
151151The implementation
152- [ ` statemgr.Filesystem ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/states/statemgr#Filesystem ) is used
152+ [ ` statemgr.Filesystem ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ states/statemgr#Filesystem ) is used
153153by default (by the ` local ` backend) and is responsible for the familiar
154154` terraform.tfstate ` local file that most Terraform users start with, before
155155they switch to [ remote state] ( https://www.terraform.io/docs/language/state/remote.html ) .
@@ -158,7 +158,7 @@ Each of these saves and retrieves state via a remote network service
158158appropriate to the backend that creates it.
159159
160160A state manager accepts and returns a state snapshot as a
161- [ ` states.State ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/states#State )
161+ [ ` states.State ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ states#State )
162162object. The state manager is responsible for exactly how that object is
163163serialized and stored, but all state managers at the time of writing use
164164the same JSON serialization format, storing the resulting JSON bytes in some
@@ -167,7 +167,7 @@ kind of arbitrary blob store.
167167## Graph Builder
168168
169169A _ graph builder_ is called by a
170- [ ` terraform.Context ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#Context )
170+ [ ` terraform.Context ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#Context )
171171method (e.g. ` Plan ` or ` Apply ` ) to produce the graph that will be used
172172to represent the necessary steps for that operation and the dependency
173173relationships between them.
@@ -177,7 +177,7 @@ In most cases, the
177177graphs each represent a specific object in the configuration, or something
178178derived from those configuration objects. For example, each ` resource ` block
179179in the configuration has one corresponding
180- [ ` GraphNodeConfigResource ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#GraphNodeConfigResource )
180+ [ ` GraphNodeConfigResource ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#GraphNodeConfigResource )
181181vertex representing it in the "plan" graph. (Terraform Core uses terminology
182182inconsistently, describing graph _ vertices_ also as graph _ nodes_ in various
183183places. These both describe the same concept.)
@@ -194,23 +194,23 @@ graph from the set of changes described in the plan that is being applied.
194194
195195The graph builders all work in terms of a sequence of _ transforms_ , which
196196are implementations of
197- [ ` terraform.GraphTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#GraphTransformer ) .
197+ [ ` terraform.GraphTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#GraphTransformer ) .
198198Implementations of this interface just take a graph and mutate it in any
199199way needed, and so the set of available transforms is quite varied. Some
200200important examples include:
201201
202- * [ ` ConfigTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#ConfigTransformer ) ,
202+ * [ ` ConfigTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#ConfigTransformer ) ,
203203 which creates a graph vertex for each ` resource ` block in the configuration.
204204
205- * [ ` StateTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#StateTransformer ) ,
205+ * [ ` StateTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#StateTransformer ) ,
206206 which creates a graph vertex for each resource instance currently tracked
207207 in the state.
208208
209- * [ ` ReferenceTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#ReferenceTransformer ) ,
209+ * [ ` ReferenceTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#ReferenceTransformer ) ,
210210 which analyses the configuration to find dependencies between resources and
211211 other objects and creates any necessary "happens after" edges for these.
212212
213- * [ ` ProviderTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#ProviderTransformer ) ,
213+ * [ ` ProviderTransformer ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#ProviderTransformer ) ,
214214 which associates each resource or resource instance with exactly one
215215 provider configuration (implementing
216216 [ the inheritance rules] ( https://www.terraform.io/docs/language/modules/develop/providers.html ) )
@@ -224,25 +224,25 @@ builder uses a different subset of these depending on the needs of the
224224operation that is being performed.
225225
226226The result of graph building is a
227- [ ` terraform.Graph ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#Graph ) , which
227+ [ ` terraform.Graph ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#Graph ) , which
228228can then be processed using a _ graph walker_ .
229229
230230## Graph Walk
231231
232232The process of walking the graph visits each vertex of that graph in a way
233233which respects the "happens after" edges in the graph. The walk algorithm
234234itself is implemented in
235- [ the low-level ` dag ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/dag#AcyclicGraph.Walk )
235+ [ the low-level ` dag ` package] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ dag#AcyclicGraph.Walk )
236236(where "DAG" is short for [ _ Directed Acyclic Graph_ ] ( https://en.wikipedia.org/wiki/Directed_acyclic_graph ) ), in
237- [ ` AcyclicGraph.Walk ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/dag#AcyclicGraph.Walk ) .
237+ [ ` AcyclicGraph.Walk ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ dag#AcyclicGraph.Walk ) .
238238However, the "interesting" Terraform walk functionality is implemented in
239- [ ` terraform.ContextGraphWalker ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#ContextGraphWalker ) ,
239+ [ ` terraform.ContextGraphWalker ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#ContextGraphWalker ) ,
240240which implements a small set of higher-level operations that are performed
241241during the graph walk:
242242
243243* ` EnterPath ` is called once for each module in the configuration, taking a
244244 module address and returning a
245- [ ` terraform.EvalContext ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#EvalContext )
245+ [ ` terraform.EvalContext ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#EvalContext )
246246 that tracks objects within that module. ` terraform.Context ` is the _ global_
247247 context for the entire operation, while ` terraform.EvalContext ` is a
248248 context for processing within a single module, and is the primary means
@@ -254,7 +254,7 @@ will evaluate multiple vertices concurrently. Vertex evaluation code must
254254therefore make careful use of concurrency primitives such as mutexes in order
255255to coordinate access to shared objects such as the ` states.State ` object.
256256In most cases, we use the helper wrapper
257- [ ` states.SyncState ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/states#SyncState )
257+ [ ` states.SyncState ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ states#SyncState )
258258to safely implement concurrent reads and writes from the shared state.
259259
260260## Vertex Evaluation
@@ -287,27 +287,27 @@ a plan operation would include the following high-level steps:
287287 this operation.
288288
289289Each execution step for a vertex is an implementation of
290- [ ` terraform.Execute ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform #Execute ) .
290+ [ ` terraform.Execute ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/erraform #Execute ) .
291291As with graph transforms, the behavior of these implementations varies widely:
292292whereas graph transforms can take any action against the graph, an ` Execute `
293293implementation can take any action against the ` EvalContext ` .
294294
295295The implementation of ` terraform.EvalContext ` used in real processing
296296(as opposed to testing) is
297- [ ` terraform.BuiltinEvalContext ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#BuiltinEvalContext ) .
297+ [ ` terraform.BuiltinEvalContext ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#BuiltinEvalContext ) .
298298It provides coordinated access to plugins, the current state, and the current
299299plan via the ` EvalContext ` interface methods.
300300
301301In order to be executed, a vertex must implement
302- [ ` terraform.GraphNodeExecutable ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#GraphNodeExecutable ) ,
302+ [ ` terraform.GraphNodeExecutable ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#GraphNodeExecutable ) ,
303303which has a single ` Execute ` method that handles. There are numerous ` Execute `
304304implementations with different behaviors, but some prominent examples are:
305305
306- * [ NodePlannableResource.Execute] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#NodePlannableResourceInstance.Execute ) , which handles the ` plan ` operation.
306+ * [ NodePlannableResource.Execute] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#NodePlannableResourceInstance.Execute ) , which handles the ` plan ` operation.
307307
308- * [ ` NodeApplyableResourceInstance.Execute ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#NodeApplyableResourceInstance.Execute ) , which handles the main ` apply ` operation.
308+ * [ ` NodeApplyableResourceInstance.Execute ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#NodeApplyableResourceInstance.Execute ) , which handles the main ` apply ` operation.
309309
310- * [ ` NodeDestroyResourceInstance.Execute ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#EvalWriteState ) , which handles the main ` destroy ` operation.
310+ * [ ` NodeDestroyResourceInstance.Execute ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#EvalWriteState ) , which handles the main ` destroy ` operation.
311311
312312A vertex must complete successfully before the graph walk will begin evaluation
313313for other vertices that have "happens after" edges. Evaluation can fail with one
@@ -327,11 +327,11 @@ The high-level process for expression evaluation is:
327327 to. For example, the expression ` aws_instance.example[1] ` refers to one of
328328 the instances created by a ` resource "aws_instance" "example" ` block in
329329 configuration. This analysis is performed by
330- [ ` lang.References ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/lang#References ) ,
330+ [ ` lang.References ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ lang#References ) ,
331331 or more often one of the helper wrappers around it:
332- [ ` lang.ReferencesInBlock ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/lang#ReferencesInBlock )
332+ [ ` lang.ReferencesInBlock ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ lang#ReferencesInBlock )
333333 or
334- [ ` lang.ReferencesInExpr ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/lang#ReferencesInExpr )
334+ [ ` lang.ReferencesInExpr ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ lang#ReferencesInExpr )
335335
3363361 . Retrieve from the state the data for the objects that are referred to and
337337 create a lookup table of the values from these objects that the
@@ -345,11 +345,11 @@ The high-level process for expression evaluation is:
345345 object) against the data and function lookup tables.
346346
347347In practice, steps 2 through 4 are usually run all together using one
348- of the methods on [ ` lang.Scope ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/lang#Scope ) ;
348+ of the methods on [ ` lang.Scope ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ lang#Scope ) ;
349349most commonly,
350- [ ` lang.EvalBlock ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/lang#Scope.EvalBlock )
350+ [ ` lang.EvalBlock ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ lang#Scope.EvalBlock )
351351or
352- [ ` lang.EvalExpr ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/lang#Scope.EvalExpr ) .
352+ [ ` lang.EvalExpr ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ lang#Scope.EvalExpr ) .
353353
354354Expression evaluation produces a dynamic value represented as a
355355[ ` cty.Value ` ] ( https://pkg.go.dev/github.com/zclconf/go-cty/cty#Value ) .
@@ -374,7 +374,7 @@ known when the main graph is constructed, but become known while evaluating
374374other vertices in the main graph.
375375
376376This special behavior applies to vertex objects that implement
377- [ ` terraform.GraphNodeDynamicExpandable ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/terraform#GraphNodeDynamicExpandable ) .
377+ [ ` terraform.GraphNodeDynamicExpandable ` ] ( https://pkg.go.dev/github.com/hashicorp/terraform/internal/ terraform#GraphNodeDynamicExpandable ) .
378378Such vertices have their own nested _ graph builder_ , _ graph walk_ ,
379379and _ vertex evaluation_ steps, with the same behaviors as described in these
380380sections for the main graph. The difference is in which graph transforms
0 commit comments