diff --git a/command/init_test.go b/command/init_test.go index 62bd484fb..6e5985944 100644 --- a/command/init_test.go +++ b/command/init_test.go @@ -671,7 +671,7 @@ func TestInit_inputFalse(t *testing.T) { } // A missing input=false should abort rather than loop infinitely - args = []string{"-backend-config=path=bar"} + args = []string{"-backend-config=path=baz"} if code := c.Run(args); code == 0 { t.Fatal("init should have failed", ui.OutputWriter) } diff --git a/command/meta_backend.go b/command/meta_backend.go index c649c3336..738a0b94f 100644 --- a/command/meta_backend.go +++ b/command/meta_backend.go @@ -463,12 +463,11 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di // Potentially changing a backend configuration case c != nil && !s.Backend.Empty(): - // If we're not initializing, then it's sufficient for the configuration - // hashes to match, since that suggests that the static backend - // settings in the configuration files are unchanged. (The only - // record we have of CLI overrides is in the settings cache in this - // case, so we have no other source to compare with. - if !opts.Init && uint64(cHash) == s.Backend.Hash { + // We are not going to migrate if were not initializing and the hashes + // match indicating that the stored config is valid. If we are + // initializing, then we also assume the the backend config is OK if + // the hashes match, as long as we're not providing any new overrides. + if (uint64(cHash) == s.Backend.Hash) && (!opts.Init || opts.ConfigOverride == nil) { log.Printf("[TRACE] Meta.Backend: using already-initialized, unchanged %q backend configuration", c.Type) return m.backend_C_r_S_unchanged(c, cHash, sMgr) } @@ -823,8 +822,6 @@ func (m *Meta) backend_C_r_S_changed(c *configs.Backend, cHash int, sMgr *state. return nil, diags } - fmt.Println("HERE") - // Perform the migration err := m.backendMigrateState(&backendMigrateOpts{ OneType: s.Backend.Type,