Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace_key_prefix contains more than one folder #16383

Closed
dpavlov-smartling opened this issue Oct 18, 2017 · 8 comments · Fixed by #16932
Closed

workspace_key_prefix contains more than one folder #16383

dpavlov-smartling opened this issue Oct 18, 2017 · 8 comments · Fixed by #16932

Comments

@dpavlov-smartling
Copy link

dpavlov-smartling commented Oct 18, 2017

Hello,

Seems like terraform isn't able to handle workspace_key_prefix which contains more than one word like:
workspace_key_prefix = "rds-test/rds-logs-download"
Actually it is able to create workspace and put terraform state file into needed path, but doesn't show it when you execute:
terraform workspace list

Initial task is to put state files of all workspaces inside sub-folder into main bucket like /BUCKET/SUB-folder1/SUB-folder2/WORKSPACE-NAME/terraform.tfstate, so I have used following backend configuratin:

terraform {
  backend "s3" {
    bucket               = "XXXXXX-terraform"
    key                  = "rds-logs-download.tfstate"
    region               = "us-east-1"
    workspace_key_prefix = "rds-test/rds-logs-download" 
  }
}

Expected Behavior

According to documentation at https://www.terraform.io/docs/backends/types/s3.html#key path should be following:
XXXXXX-terraform/rds-test/rds-logs-download/<WORKSPACE_NAME>/rds-logs-download.tfstate

Actual Behavior

terraform workspace new test2
Created and switched to workspace "test2"!

terraform workspace list
  default

terraform workspace new test3
Created and switched to workspace "test3"!

terraform workspace list
  default

While it DOES create structure inside S3 backet:
aws s3 ls XXXXXXXXX-terraform/rds-test/rds-logs-download/test
PRE test2/
PRE test3/

Steps to Reproduce

Just try to use backend as was provided above and create few workspaces.

terraform version
Terraform v0.10.7

@completenovice
Copy link

This is affecting us too, it is stopping us rolling out workspaces to our teams as it is not clear on which workspace a user is on.

@xatnys
Copy link

xatnys commented Dec 14, 2017

Also affecting us.

@mbowiewilson
Copy link

mbowiewilson commented Feb 14, 2018

I'm still having this problem with v0.11.3.. Is anyone else?

@redbaron
Copy link

redbaron commented Mar 5, 2018

@mbowiewilson , @jbardin I can confirm that with TF 0.11.3 this is still not solved. terraform workspace select <name> doesn't find workspace

@jbardin
Copy link
Member

jbardin commented Mar 5, 2018

@mbowiewilson, @redbaron: If you have a reproducible case, please feel free to open a new issue and we can look into it. Thanks!

@redbaron
Copy link

redbaron commented Mar 5, 2018

@jbardin IMHO it is better to have this issue reopened as problem described here is not solved. My reproducible test case is like for like with one reported here , with slight variation to actual values used:

terraform {
  backend "s3" {
    bucket = "XXXX-terraform" 
    key = "pubweb.tfstate"
    region = "eu-west-2"
    workspace_key_prefix = "pubweb/env:"
  }
}

@jbardin
Copy link
Member

jbardin commented Mar 5, 2018

@redbaron,

While the issue may look superficially similar, I'd rather have a new issue open if the underlying cause if different.

Can you provide the steps required to reproduce an issue with your configuration? What you have here should work as expected. Using your configuration:

$ tf init
Terraform has been successfully initialized!
...
$ tf workspace list
* default

$ tf workspace new foo
Created and switched to workspace "foo"!

$ tf workspace new bar
Created and switched to workspace "bar"!

$ tf workspace list
  default
* bar
  foo

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants