diff --git a/linode/instance/helpers.go b/linode/instance/helpers.go index e4f03ccbb..6d1b4f5eb 100644 --- a/linode/instance/helpers.go +++ b/linode/instance/helpers.go @@ -754,9 +754,23 @@ func changeInstanceType( diskResize bool, d *schema.ResourceData, ) (*linodego.Instance, error) { - instance, err := ensureInstanceOffline(ctx, client, instanceID, getDeadlineSeconds(ctx, d)) - if err != nil { - return nil, err + var err error + var instance *linodego.Instance + + if migrationType == linodego.ColdMigration { + // Cold migration: Ensure instance is offline + tflog.Info(ctx, "Cold migration selected: shutting down instance before resize") + instance, err = ensureInstanceOffline(ctx, client, instanceID, getDeadlineSeconds(ctx, d)) + if err != nil { + return nil, fmt.Errorf("failed to shut down instance for cold migration: %w", err) + } + } else { + // Warm migration: Get the current instance state + tflog.Info(ctx, "Warm migration selected: instance will resize while running") + instance, err = client.GetInstance(ctx, instanceID) + if err != nil { + return nil, fmt.Errorf("failed to fetch instance details for warm migration: %w", err) + } } var primaryDisk *linodego.InstanceDisk