@@ -30,6 +30,7 @@ import (
3030 "github.com/hashicorp/terraform/internal/command/views"
3131 "github.com/hashicorp/terraform/internal/configs"
3232 "github.com/hashicorp/terraform/internal/configs/configschema"
33+ "github.com/hashicorp/terraform/internal/depsfile"
3334 "github.com/hashicorp/terraform/internal/didyoumean"
3435 "github.com/hashicorp/terraform/internal/getproviders"
3536 "github.com/hashicorp/terraform/internal/providercache"
@@ -187,7 +188,11 @@ func (c *InitCommand) Run(args []string) int {
187188 case initArgs .Cloud && rootModEarly .CloudConfig != nil :
188189 back , backendOutput , backDiags = c .initCloud (ctx , rootModEarly , initArgs .BackendConfig , initArgs .ViewType , view )
189190 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 )
191196 default :
192197 // load the previously-stored backend config
193198 back , backDiags = c .Meta .backendFromState (ctx )
@@ -420,7 +425,7 @@ func (c *InitCommand) initCloud(ctx context.Context, root *configs.Module, extra
420425 return back , true , diags
421426}
422427
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 ) {
424429 ctx , span := tracer .Start (ctx , "initialize backend" )
425430 _ = ctx // prevent staticcheck from complaining to avoid a maintenence hazard of having the wrong ctx in scope here
426431 defer span .End ()
@@ -534,6 +539,7 @@ func (c *InitCommand) initBackend(ctx context.Context, root *configs.Module, ext
534539
535540 opts = & BackendOpts {
536541 StateStoreConfig : root .StateStore ,
542+ Locks : locks ,
537543 ProviderFactory : factory ,
538544 ConfigOverride : configOverride ,
539545 Init : true ,
0 commit comments