@@ -30,6 +30,7 @@ import (
30
30
"github.com/hashicorp/terraform/internal/command/views"
31
31
"github.com/hashicorp/terraform/internal/configs"
32
32
"github.com/hashicorp/terraform/internal/configs/configschema"
33
+ "github.com/hashicorp/terraform/internal/depsfile"
33
34
"github.com/hashicorp/terraform/internal/didyoumean"
34
35
"github.com/hashicorp/terraform/internal/getproviders"
35
36
"github.com/hashicorp/terraform/internal/providercache"
@@ -187,7 +188,11 @@ func (c *InitCommand) Run(args []string) int {
187
188
case initArgs .Cloud && rootModEarly .CloudConfig != nil :
188
189
back , backendOutput , backDiags = c .initCloud (ctx , rootModEarly , initArgs .BackendConfig , initArgs .ViewType , view )
189
190
case initArgs .Backend :
190
- back , backendOutput , backDiags = c .initBackend (ctx , rootModEarly , initArgs .BackendConfig , initArgs .ViewType , view )
191
+ // This handles case when config contains either backend or state_store blocks.
192
+ // This is valid as either can be implementations of backend.Backend, which is what we
193
+ // obtain here.
194
+ var locks * depsfile.Locks
195
+ back , backendOutput , backDiags = c .initBackend (ctx , rootModEarly , initArgs .BackendConfig , initArgs .ViewType , locks , view )
191
196
default :
192
197
// load the previously-stored backend config
193
198
back , backDiags = c .Meta .backendFromState (ctx )
@@ -420,7 +425,7 @@ func (c *InitCommand) initCloud(ctx context.Context, root *configs.Module, extra
420
425
return back , true , diags
421
426
}
422
427
423
- func (c * InitCommand ) initBackend (ctx context.Context , root * configs.Module , extraConfig arguments.FlagNameValueSlice , viewType arguments.ViewType , view views.Init ) (be backend.Backend , output bool , diags tfdiags.Diagnostics ) {
428
+ func (c * InitCommand ) initBackend (ctx context.Context , root * configs.Module , extraConfig arguments.FlagNameValueSlice , viewType arguments.ViewType , locks * depsfile. Locks , view views.Init ) (be backend.Backend , output bool , diags tfdiags.Diagnostics ) {
424
429
ctx , span := tracer .Start (ctx , "initialize backend" )
425
430
_ = ctx // prevent staticcheck from complaining to avoid a maintenence hazard of having the wrong ctx in scope here
426
431
defer span .End ()
@@ -534,6 +539,7 @@ func (c *InitCommand) initBackend(ctx context.Context, root *configs.Module, ext
534
539
535
540
opts = & BackendOpts {
536
541
StateStoreConfig : root .StateStore ,
542
+ Locks : locks ,
537
543
ProviderFactory : factory ,
538
544
ConfigOverride : configOverride ,
539
545
Init : true ,
0 commit comments