Error loading state: workspaces not supported

Hi everyone,

I am using Terraform cloud with workspace === staging

I am using this line in one of my tf files:
name = “${terraform.workspace}-mongodb”

When the plan is triggered i have “default-mongodb” instead of “staging-mongodb”
When i use TF_WORKSPACE == “staging” as ENV VAR in the terraform cloud console i have an error: “Error loading state: workspaces not supported”

Can anyone tell me how to solve this please !!

Best

1 Like

Hi,
Did you ever resolve this?
I’m getting similar:

running "/usr/bin/terraform init -input=false -upgrade -backend-config=development.tfbackend" in "/root/repos/my-repo-name": exit status 1

Initializing the backend...
Error loading state: workspaces not supported

My main.tf contains:

# Terraform Cloud
terraform {
  backend "remote" {}
}

My development.tfbackend is:

hostname     = "app.terraform.io"
organization = "MYORG"
workspaces {name = "My-Workspace-Name"}

However, if I have just the following in the main.tf and no .tfbackend file:

# Terraform Cloud
terraform {
  backend "remote" {
    hostname     = "app.terraform.io"
    organization = "MYORG"
    workspaces {
      name = "My-Workspace-Name"
    }
  }
}

EDIT: above doesn’t work for me now, although it used to do :frowning:

As I want to specify different Terraform Workspaces in my deployment (difference being between a prod and dev version) I can’t have the workspace hardcoded.
Can anyone suggest a fix?

Thanks,
Richie

I had this issue and found I already had the TF_WORKSPACE env var set to something else, this fixed it for me:

unset TF_WORKSPACE
3 Likes