diff --git a/terraform/context_import.go b/terraform/context_import.go index 81bc7a98a6..71edfe2b19 100644 --- a/terraform/context_import.go +++ b/terraform/context_import.go @@ -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! diff --git a/terraform/graph_builder_import.go b/terraform/graph_builder_import.go index e62c34f419..e7d6d20c78 100644 --- a/terraform/graph_builder_import.go +++ b/terraform/graph_builder_import.go @@ -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{},