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

Add configurable workspace prefix for S3 Backend #15370

Merged
merged 3 commits into from
Jun 27, 2017

Conversation

rowleyaj
Copy link
Contributor

Fixes #13184, addresses part of #15358

@jbardin @apparentlymart this is my first foray into the world of Go so go please go easy :)

Does this address the points raised in the other issue? The tests still pass although I'm not sure how to add some specifically related to this. I've also tested it locally and it successfully migrated my dummy setup from the old state structure to the new.

$ tree
.
├── env: # Old structure
│   ├── testing
│   │   └── v1
│   │       └── terraform-remote-state-example
│   ├── testing2
│       └── v1
│           └── terraform-remote-state-example
├── terraform-state # New Structure
│   ├── testing
│   │   └── v1
│   │       └── terraform-remote-state-example
│   └── testing2
│       └── v1
│           └── terraform-remote-state-example
└── v1 # Default workspace
    └── terraform-remote-state-example
terraform {
  required_version = "~> 0.10"

  backend "s3" {
    bucket  = "rowleyaj-tf-state-demo"
    key     = "v1/terraform-remote-state-example"
    region  = "us-east-1"
    encrypt = true

    dynamodb_table = "rowleyaj-terraform-state-lock"
    workspace_key_prefix = "terraform-state"
  }
}

@rowleyaj
Copy link
Contributor Author

Not sure why tests are failing on this but I don't think it's related, any help appreciated:

--- FAIL: TestResourceProvider_stop (2.05s)
	resource_provisioner_test.go:80: should finish
FAIL
FAIL	github.com/hashicorp/terraform/builtin/provisioners/local-exec	4.192s

@rowleyaj
Copy link
Contributor Author

Tests pass now, was a strange timeout :)

Copy link
Contributor

@josephholsten josephholsten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but we may want to mention the default in the doc

@@ -108,3 +108,5 @@ The following configuration options or environment variables are supported:
* `assume_role_policy` - (Optional) The permissions applied when assuming a role.
* `external_id` - (Optional) The external ID to use when assuming the role.
* `session_name` - (Optional) The session name to use when assuming the role.
* `workspace_key_prefix` - (Optional) The prefix applied to the state path inside the bucket.
This is only relevant when using a non-default workspace.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we mention the default is "env:"?

Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Just a minor doc-string update before merging, but otherwise, LGTM!

"workspace_key_prefix": {
Type: schema.TypeString,
Optional: true,
Description: "The prefix applied to the state path inside the bucket",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we mention that it's for non-default workspaces here? Maybe:

applied to the non-default state path

@ghost
Copy link

ghost commented Apr 8, 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 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configurable keyEnvPrefix
4 participants