diff --git a/backend/backend.go b/backend/backend.go index 0139b5ad3..50cf14465 100644 --- a/backend/backend.go +++ b/backend/backend.go @@ -6,6 +6,7 @@ package backend import ( "context" + "errors" "github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/state" @@ -14,6 +15,9 @@ import ( const DefaultStateName = "default" +// Error value to return when a named state operation isn't supported +var ErrNamedStatesNotSupported = errors.New("named states not supported") + // Backend is the minimal interface that must be implemented to enable Terraform. type Backend interface { // Ask for input and configure the backend. Similar to diff --git a/backend/legacy/backend.go b/backend/legacy/backend.go index 21ed7b1fb..a8b0cad9f 100644 --- a/backend/legacy/backend.go +++ b/backend/legacy/backend.go @@ -3,6 +3,7 @@ package legacy import ( "fmt" + "github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/state" "github.com/hashicorp/terraform/state/remote" "github.com/hashicorp/terraform/terraform" @@ -53,10 +54,22 @@ func (b *Backend) Configure(c *terraform.ResourceConfig) error { return nil } -func (b *Backend) State() (state.State, error) { +func (b *Backend) State(name string) (state.State, error) { + if name != backend.DefaultStateName { + return nil, backend.ErrNamedStatesNotSupported + } + if b.client == nil { panic("State called with nil remote state client") } return &remote.State{Client: b.client}, nil } + +func (b *Backend) States() ([]string, error) { + return nil, backend.ErrNamedStatesNotSupported +} + +func (b *Backend) DeleteState(string) error { + return backend.ErrNamedStatesNotSupported +} diff --git a/backend/legacy/backend_test.go b/backend/legacy/backend_test.go index eceb48510..b46ed9252 100644 --- a/backend/legacy/backend_test.go +++ b/backend/legacy/backend_test.go @@ -34,7 +34,7 @@ func TestBackend(t *testing.T) { } // Grab state - s, err := b.State() + s, err := b.State(backend.DefaultStateName) if err != nil { t.Fatalf("err: %s", err) } diff --git a/backend/local/backend.go b/backend/local/backend.go index 2413d9ee3..a6329404c 100644 --- a/backend/local/backend.go +++ b/backend/local/backend.go @@ -27,8 +27,6 @@ const ( DefaultBackupExtension = ".backup" ) -var ErrEnvNotSupported = errors.New("environments not supported") - // Local is an implementation of EnhancedBackend that performs all operations // locally. This is the "default" backend and implements normal Terraform // behavior as it is well known.