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

modules using the same backend bucket but different paths show each others envs #14943

Closed
nfplatzke opened this issue May 30, 2017 · 5 comments
Closed

Comments

@nfplatzke
Copy link

nfplatzke commented May 30, 2017

I currently have two repositories both writing their backend files to the same s3 bucket but in different paths like so:

terraform {
backend "s3" {
bucket = "mybucket"
key = "app1/terraform.tfstate"
region = "us-east-1"
}
}

terraform {
backend "s3" {
bucket = "mybucket"
key = "app2/terraform.tfstate"
region = "us-east-1"
}
}

I am using terraform environments to handle environmental settings in different ways for each application. For app1 I've defined the env as a list of clients. So I have three environments: partner1, partner2, and partner3

I am using terraform environments for app2 for our staging and production environments.

So when I look at the list of environments from either repository I see something that looks like this:
$ terraform env list
default
partner1
partner2
partner3
production
staging

This is because even though the key is different it gets prepended by :env so terraform is looking in one folder for information about the repository.

I'd like to be able to specify where in the path the ":env" folder is created.

If the paths above were created like "app1/:env/terraform.tfstate" and "app2/:env/terraform.tfstate" it would fix this problem. Or at least have it so that a "terraform env list" only shows those environments that match the specified key instead of everything in the env folder.

Currently the only way around this is to have a different s3 bucket for every repository.

@JamesThorpe
Copy link

I'd also like to see better handling of the key names in this area. It's not so much the conflicting environments that are affecting me, more that I'd just like to have more control over it so it doesn't sit directly under the bucket root - I'd at least like to add in eg terraform\ before env:.

@rowleyaj
Copy link
Contributor

@nfplatzke what version of Terraform are you using?

I believe this was fixed in 0.9.3 with this commit: 9c431ae

I've just tested it with a version based on master and if the keys are different the environments/workspaces listed don't collide.

@rowleyaj
Copy link
Contributor

@JamesThorpe you might prefer to follow #13184 which proposes exposing the prefix used.

@jbardin
Copy link
Member

jbardin commented Aug 8, 2017

Thanks @rowleyaj, this was closed by #13596.

@jbardin jbardin closed this as completed Aug 8, 2017
@ghost
Copy link

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

No branches or pull requests

5 participants