Cloud vs remote backend questions

Hello,

  1. why the workspace command only works with cloud backend and not with remote?

  2. why the cloud backend is not listed with other types of the backends here - Terraform Cloud Settings - Terraform CLI | Terraform | HashiCorp Developer vs Backend Type: remote | Terraform | HashiCorp Developer

  3. in case of remote backend, how can i list all objects in a certain workspace using cli ?

Thank you.

Example:

backend.tf:

terraform {
  backend "remote" {
    organization = "XXX"
    workspaces {
      name = "XXXX_COMMON-RDS"
    }
  }
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 3.65.0"
    }
    tfe = {
      version = "~> 0.43.0"
    }
  }
}
...

and the cli:

terraform workspace list
workspaces not supported

Hi @AZZ - you may be better off asking in Terraform - HashiCorp Discuss for more discussion, but if I use prefix instead of name this works for me.

I added a workspace named XXXX_COMMON-RDS like your example, but set my backend.tf like this

terraform {
  backend "remote" {
    organization = "notreallyjonathanfrappier"
    workspaces {
      prefix = "XXXX_COMMON-"
    }
  }
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 3.65.0"
    }
    tfe = {
      version = "~> 0.43.0"
    }
  }
}

Now the workspace command works.

init

terraform init

Initializing the backend...

Successfully configured the backend "remote"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding hashicorp/aws versions matching ">= 3.65.0"...
- Finding hashicorp/tfe versions matching "~> 0.43.0"...
- Installing hashicorp/aws v5.23.1...
- Installed hashicorp/aws v5.23.1 (signed by HashiCorp)
- Installing hashicorp/tfe v0.43.0...
- Installed hashicorp/tfe v0.43.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

list

terraform workspace list
* RDS
1 Like

This was bothering me, but I didn’t have time until today.
As per latest documentation :
Note: The CLI integration is available in Terraform 1.1.0 and later, and Terraform Enterprise 202201-1 and later. Previous versions can use the remote backend. Refer to Migrating from the remote backend for details about switching to the CLI integration.

That implies TF is sun-setting the “remote” backend setting.

Thanks for bringing that up - I don’t have any visibility into the Terraform roadmap but would suggest connecting with your account manager to clarify. I read that section/page differently than relying on remote back ends for Terraform Community Edition (but I could certainly be interpreting that incorrectly).

While not official, someone I just spoke with said using TFC as a remote backend will not go away for the foreseeable future but I still think your best bet would be connecting with your account manager for confirmation.

That person did also mention the preference is to use the cloud block instead of remote:

I have not tried this personally.

@jonathanfrappier , thank you for the update!
It does make sense to keep “backend”.

my connection setup is generated on the fly, so switching from the “backend” to the “cloud” was a matter of updating 2 lines in a template ( plus re-running “init” ).

Thank you and Happy New Year!
AZZ

1 Like

Happy new year to you too!

1 Like