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.76k stars 9.56k forks source link

Misleading message when creating workspaces with a state file #27639

Open leriksen opened 3 years ago

leriksen commented 3 years ago

When creating a terraform workspace using the CLI, and providing an existing state file with the -state=<path> argument, a misleading success message states that a subsequent terraform plan will operate on an empty state.

The success message when creating a workspace and populating with an existing state should reflect the plans execution against that state.

Terraform Version

Terraform v0.14.5

Terraform Configuration Files

# this is a CLI issue, not a config issue

Debug Output

Crash Output

Expected Behavior

A message stating the workspace has been created with the provided state

Actual Behavior

Created and switched to workspace "xxx"!

You're now on a new, empty workspace. Workspaces isolate their state,
so if you run "terraform plan" Terraform will not see any existing state
for this configuration.

Steps to Reproduce

  1. terraform workspace new -state=<somestate.tf> newname

Additional Context

References

leriksen commented 3 years ago

Raised PR 27640 as a proposed fix

https://github.com/hashicorp/terraform/pull/27640