Merge pull request #27545 from hashicorp/alisdair/remote-backend-version-check-state-migration

cli: Fix state migration remote version check
This commit is contained in:
Alisdair McDiarmid 2021-01-20 11:07:59 -05:00 committed by GitHub
commit a7d50d3264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -70,6 +70,19 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
opts.twoEnv = backend.DefaultStateName opts.twoEnv = backend.DefaultStateName
opts.force = m.forceInitCopy opts.force = m.forceInitCopy
// Disregard remote Terraform version for the state source backend. If it's a
// Terraform Cloud remote backend, we don't care about the remote version,
// as we are migrating away and will not break a remote workspace.
m.ignoreRemoteBackendVersionConflict(opts.One)
// Check the remote Terraform version for the state destination backend. If
// it's a Terraform Cloud remote backend, we want to ensure that we don't
// break the workspace by uploading an incompatible state file.
diags := m.remoteBackendVersionCheck(opts.Two, opts.twoEnv)
if diags.HasErrors() {
return diags.Err()
}
// Determine migration behavior based on whether the source/destination // Determine migration behavior based on whether the source/destination
// supports multi-state. // supports multi-state.
switch { switch {