tfc apply before init

https://app.asana.com/0/1199201948575144/1201019450474843/f
This commit is contained in:
Barrett Clark 2021-10-19 10:20:11 -05:00 committed by Chris Arcand
parent e49f271eb5
commit d29532cfeb
1 changed files with 14 additions and 0 deletions

View File

@ -592,6 +592,20 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di
return m.backend_c_r_S(c, cHash, sMgr, true)
// Configuring Terraform Cloud for the first time.
case c != nil && c.Type == "cloud" && s.Backend.Empty():
log.Printf("[TRACE] Meta.Backend: moving from default local state only to Terraform Cloud")
if !opts.Init {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Terraform Cloud has been configured but needs to be initialized.",
"Run \"terraform init\" to initialize Terraform Cloud.",
))
return nil, diags
}
return m.backend_C_r_s(c, cHash, sMgr)
// Configuring a backend for the first time.
case c != nil && s.Backend.Empty():
log.Printf("[TRACE] Meta.Backend: moving from default local state only to %q backend", c.Type)