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
41.67k stars 9.41k forks source link

`terraform workspace list` on non terraform directory #20132

Open vkatsikaros opened 5 years ago

vkatsikaros commented 5 years ago
$ terraform -v
Terraform v0.11.11
+ provider.aws v1.9.0

The terraform workspace current documentation says:

Usage: terraform workspace list The command will list all existing workspaces

In directories where there is no terraform code, terraform workspace list still reports the default workspace. I apologize if I have missed an terraform workspace concept that explains the behavior.

Expected Behavior

$ cd /
$ terraform workspace list
$

Actual Behavior

$ cd /
$ terraform workspace list
* default

$

Steps to Reproduce

The steps are simple and unrelated to terraform configuration files, so the "Expected Behavior" section above covers reproduction.

mildwonkey commented 5 years ago

Hi @vkatsikaros - I like your icon 😀 !

terraform workspace list lists the existing workspace in your current working directory. The default workspace always exists - even if there are no terraform configuration files present in the working directory. You might consider it a "potential" workspace.

Having said that, I can see how this is confusing - personally I would expect terraform workspace list to print a notification that no terraform configuration was found in the current directory. I'm going to flag this as an enhancement and see what the rest of the core team thinks.

Thanks for opening this issue!

vkatsikaros commented 5 years ago

@mildwonkey I like yours too :)

Thanks for the detailed explanation. Let me know how this goes. I'd be interested in working on the issue if it's something that isn't a priority, it's not very complicated and if there are some starting pointers.