Skip to content

Commit

Permalink
Fixes Issue #29959, Apply w/o init error message
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
barrettclark committed Dec 1, 2021
1 parent d72a413 commit e08a02e
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions internal/command/meta_backend.go
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e08a02e

Please sign in to comment.