Migrate from s3 multi workspace backend to terraform cloud

I’ve been using terraform S3 backend and I want to migrate to Terraform Cloud. Though I configure the remote backend and do terraform init -migrate-state, the state is not saved in Terraform cloud workspace and still gets pushed to s3.
I tried to remove .terraform and reinit the process with the same results.
Any hits are appreciated.

Hi, welcome to the forum!

  • Are you using multiple states (workspaces) or a single S3 state?
  • When configuring the remote backend, are you using name or prefix for your workspaces block?
  • When you run terraform init -migrate-state, what happens? Do you get prompted to migrate state?
  • You have a workspace in Terraform Cloud, I’m guessing - is the workspace empty, with no States present?


Thanks for the reply.
I’m trying to use prefix to be able to run the local multi workspace original structure while migrating it to tf cloud.
If I use prefix, I can see the workspaces and it works but by using s3 state even with the backend configured to use tf cloud.
Only if I use name, the state is used in tf cloud but I loose the multi workspace option.

I runned -migrate-state and everything is shown as correct, but in the end, the state remains in the old s3 backend.

The workspaced in TF cloud are some empty and others, I already migrated the state while testing with the name option

Sorry for the delayed reply!

Hmm, I think what’s most interesting about this is not that -migrate-state didn’t work, but the following:

Though I configure the remote backend…the state is not saved in Terraform cloud workspace and still gets pushed to s3.

Can you show any snippets of your backend configuration block? If the backend block in question is being used, it should not be possible for Terraform to execute most things (like apply) without addressing the change in backend configuration by running init. That is, if you have the backend configured for something other than S3, it should not be possible for it to continue using it without reinitializing the working directory.