core: Give import graph access to schema, variables, outputs, locals
During import we constrain provider configuration to allow only references to variables, but since provider configurations in child modules might refer to variables from the parent, we still need to include the module variables, outputs and locals in the graph here and attach the provider schemas. In future a better check would be that the provider configuration doesn't refer to anything that is currently unknown, but we'll save that for another day.
This commit is contained in:
parent
fc8030d2ae
commit
30d6a40329
|
@ -60,7 +60,7 @@ func (c *Context) Import(opts *ImportOpts) (*State, tfdiags.Diagnostics) {
|
|||
builder := &ImportGraphBuilder{
|
||||
ImportTargets: opts.Targets,
|
||||
Config: config,
|
||||
Providers: c.components.ResourceProviders(),
|
||||
Components: c.components,
|
||||
}
|
||||
|
||||
// Build the graph!
|
||||
|
|
|
@ -17,8 +17,8 @@ type ImportGraphBuilder struct {
|
|||
// Module is a configuration to build the graph from. See ImportOpts.Config.
|
||||
Config *configs.Config
|
||||
|
||||
// Providers is the list of providers supported.
|
||||
Providers []string
|
||||
// Components is the factory for our available plugin components.
|
||||
Components contextComponentFactory
|
||||
}
|
||||
|
||||
// Build builds the graph according to the steps returned by Steps.
|
||||
|
@ -54,11 +54,31 @@ func (b *ImportGraphBuilder) Steps() []GraphTransformer {
|
|||
// Add the import steps
|
||||
&ImportStateTransformer{Targets: b.ImportTargets},
|
||||
|
||||
TransformProviders(b.Providers, concreteProvider, config),
|
||||
// Add root variables
|
||||
&RootVariableTransformer{Config: b.Config},
|
||||
|
||||
// Must be before TransformProviders and ReferenceTransformer, since
|
||||
// schema is required to extract references from config.
|
||||
&AttachSchemaTransformer{Components: b.Components},
|
||||
|
||||
TransformProviders(b.Components.ResourceProviders(), concreteProvider, config),
|
||||
|
||||
// This validates that the providers only depend on variables
|
||||
&ImportProviderValidateTransformer{},
|
||||
|
||||
// Add the local values
|
||||
&LocalTransformer{Config: b.Config},
|
||||
|
||||
// Add the outputs
|
||||
&OutputTransformer{Config: b.Config},
|
||||
|
||||
// Add module variables
|
||||
&ModuleVariableTransformer{Config: b.Config},
|
||||
|
||||
// Connect so that the references are ready for targeting. We'll
|
||||
// have to connect again later for providers and so on.
|
||||
&ReferenceTransformer{},
|
||||
|
||||
// Close opened plugin connections
|
||||
&CloseProviderTransformer{},
|
||||
|
||||
|
|
Loading…
Reference in New Issue