Skip to content

Commit 6594652

Browse files
committed
Let consumer override the environment in remote_state module
1 parent 8e597e7 commit 6594652

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

modules/remote_state/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
locals {
2+
env = coalesce(var.environment, terraform.workspace)
3+
}
4+
15
data "terraform_remote_state" "this" {
26
backend = "s3"
37

48
config = {
59
bucket = var.state_bucket
6-
key = "env:/${terraform.workspace}/${var.component}.tfstate"
10+
key = "env:/${local.env}/${var.component}.tfstate"
711
}
812
}
913

modules/remote_state/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
variable "environment" {
2+
type = string
3+
default = ""
4+
}
5+
16
variable "component" {
27
type = string
38
}

0 commit comments

Comments
 (0)