hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.1k stars 9.47k forks source link

No longer possible to create workspaces without the "default" workspace for different backend types #30265

Open drastawi opened 2 years ago

drastawi commented 2 years ago

Hey, I just wanted to highlight the following issue #30129 (fixed with #30142) seems to apply to more backends than just the "remote". In my case I had an issue in with my "pg" backend.

This flow is quite widely used when running terraform in automation where it might not make sense to init the "default" workspace (e.g. due to permissions issues).

Terraform Version

main and 1.1.2

Terraform Configuration Files

terraform {
    backend "pg" {
        schema_name = "shared"
    }
}

Debug Output

Expected Behavior

Actual Behavior

Steps to Reproduce

The symptoms are the same as in the original issue. Running terraform init in any new workspace (specified by TF_WORKSPACE or .terraform/environment) will result in:

Error: Failed to select workspace

and a subsequent terraform workspace new will result in:

Backend initialization required, please run "terraform init"

The only difference would be the config.

Additional Context

References

crw commented 2 years ago

Thanks for the report! Added it to the triage list.

komealy commented 2 years ago

We use the "s3" backend and see this issue as well.