Skip to content

Commit 23505cc

Browse files
authored
Merge pull request hashicorp#12818 from hashicorp/b-legacy
command: use backendinit instead of initializing legacy directly
2 parents 434e781 + 4f59576 commit 23505cc

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎command/meta_backend.go‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/hashicorp/terraform/terraform"
2424
"github.com/mitchellh/mapstructure"
2525

26-
backendlegacy "github.com/hashicorp/terraform/backend/legacy"
2726
backendlocal "github.com/hashicorp/terraform/backend/local"
2827
)
2928

@@ -1325,8 +1324,12 @@ func (m *Meta) backendInitFromLegacy(s *terraform.RemoteState) (backend.Backend,
13251324
}
13261325
config := terraform.NewResourceConfig(rawC)
13271326

1328-
// Initialize the legacy remote backend
1329-
b := &backendlegacy.Backend{Type: s.Type}
1327+
// Get the backend
1328+
f := backendinit.Backend(s.Type)
1329+
if f == nil {
1330+
return nil, fmt.Errorf(strings.TrimSpace(errBackendLegacyUnknown), s.Type)
1331+
}
1332+
b := f()
13301333

13311334
// Configure
13321335
if err := b.Configure(config); err != nil {
@@ -1381,7 +1384,7 @@ If fixing these errors requires changing your remote state configuration,
13811384
you must switch your configuration to the new remote backend configuration.
13821385
You can learn more about remote backends at the URL below:
13831386
1384-
TODO: URL
1387+
https://www.terraform.io/docs/backends/index.html
13851388
13861389
The error(s) configuring the legacy remote state:
13871390
@@ -1391,7 +1394,7 @@ The error(s) configuring the legacy remote state:
13911394
const errBackendLegacyUnknown = `
13921395
The legacy remote state type %q could not be found.
13931396
1394-
Terraform 0.9.0 shipped with backwards compatible for all built-in
1397+
Terraform 0.9.0 shipped with backwards compatibility for all built-in
13951398
legacy remote state types. This error may mean that you were using a
13961399
custom Terraform build that perhaps supported a different type of
13971400
remote state.

0 commit comments

Comments
 (0)