Merge pull request #29793 from hashicorp/alisdair/fix-remote-backend-migrate-version-check
backend/remote: Fix version check when migrating
This commit is contained in:
commit
22923f9873
|
@ -77,15 +77,28 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
|
||||||
// as we are migrating away and will not break a remote workspace.
|
// as we are migrating away and will not break a remote workspace.
|
||||||
m.ignoreRemoteBackendVersionConflict(opts.Source)
|
m.ignoreRemoteBackendVersionConflict(opts.Source)
|
||||||
|
|
||||||
for _, workspace := range destinationWorkspaces {
|
// Disregard remote Terraform version if instructed to do so via CLI flag.
|
||||||
|
if m.ignoreRemoteVersion {
|
||||||
|
m.ignoreRemoteBackendVersionConflict(opts.Destination)
|
||||||
|
} else {
|
||||||
// Check the remote Terraform version for the state destination backend. If
|
// 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
|
// it's a Terraform Cloud remote backend, we want to ensure that we don't
|
||||||
// break the workspace by uploading an incompatible state file.
|
// break the workspace by uploading an incompatible state file.
|
||||||
|
for _, workspace := range destinationWorkspaces {
|
||||||
diags := m.remoteBackendVersionCheck(opts.Destination, workspace)
|
diags := m.remoteBackendVersionCheck(opts.Destination, workspace)
|
||||||
if diags.HasErrors() {
|
if diags.HasErrors() {
|
||||||
return diags.Err()
|
return diags.Err()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If there are no specified destination workspaces, perform a remote
|
||||||
|
// backend version check with the default workspace.
|
||||||
|
if len(destinationWorkspaces) == 0 {
|
||||||
|
diags := m.remoteBackendVersionCheck(opts.Destination, backend.DefaultStateName)
|
||||||
|
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.
|
||||||
|
|
Loading…
Reference in New Issue