Fixes Issue #29959, Apply w/o init error message

When going from a local backend to Terraform Cloud, if you skip the
`terraform init` and run `terraform apply` this will give the user more
clear instructions.
This commit is contained in:
Barrett Clark 2021-12-01 11:09:46 -06:00
parent d72a413ef8
commit e08a02e7bf
1 changed files with 1 additions and 12 deletions

View File

@ -737,7 +737,7 @@ func (m *Meta) determineInitReason(previousBackendType string, currentBackendTyp
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Terraform Cloud initialization required: please run \"terraform init\"",
fmt.Sprintf(strings.TrimSpace(errBackendInitCloudMigration), initReason),
fmt.Sprintf(strings.TrimSpace(errBackendInitCloud), initReason),
))
default:
diags = diags.Append(tfdiags.Sourceless(
@ -1510,17 +1510,6 @@ hasn't changed and try again. At this point, no changes to your existing
configuration or state have been made.
`
const errBackendInitCloudMigration = `
Reason: %s.
Migrating to Terraform Cloud requires reinitialization, to discover which Terraform Cloud workspaces belong to this configuration and to optionally migrate existing state to the corresponding Terraform Cloud workspaces.
To re-initialize, run:
terraform init
Terraform has not yet made changes to your existing configuration or state.
`
const errBackendInitCloud = `
Reason: %s.