Skip to content

Commit 3c7ac8f

Browse files
authored
Fix bug introduced in v1.3.0 by #57 (#58)
1 parent a7e87a4 commit 3c7ac8f

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

modules/remote-state/data_source.tf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
locals {
2+
data_source_backends = ["remote", "s3"]
3+
is_data_source_backend = contains(local.data_source_backends, local.backend_type)
4+
25
remote_workspace = var.workspace != null ? var.workspace : local.workspace
3-
ds_backend = contains(["remote", "s3"], local.backend_type) ? local.backend_type : "local"
6+
ds_backend = local.is_data_source_backend ? local.backend_type : "local"
47
ds_workspace = local.ds_backend == "local" ? null : local.remote_workspace
58

69
ds_configurations = {
710
local = {
811
path = "${path.module}/dummy-remote-state.json"
912
}
1013

11-
remote = local.ds_backend == "remote" ? {
14+
remote = local.ds_backend != "remote" ? null : {
1215
organization = local.backend.organization
1316

1417
workspaces = {
1518
name = local.remote_workspace
1619
}
17-
} : null
20+
}
1821

19-
s3 = local.ds_backend == "s3" ? {
22+
s3 = local.ds_backend != "s3" ? null : {
2023
encrypt = local.backend.encrypt
2124
bucket = local.backend.bucket
2225
key = local.backend.key
@@ -69,7 +72,7 @@ locals {
6972
profile = !coalesce(try(local.backend.privileged, null), var.privileged) && contains(keys(local.backend), "profile") ? local.backend.profile : null
7073

7174
workspace_key_prefix = local.workspace_key_prefix
72-
} : null
75+
}
7376
} # ds_configurations
7477

7578

modules/remote-state/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ locals {
4141
static = local.backend
4242
}
4343

44-
remote_state_backend_key = var.bypass ? "bypass" : local.backend_type
44+
remote_state_backend_key = var.bypass ? "bypass" : local.is_data_source_backend ? "data_source" : local.backend_type
4545
computed_remote_state_backend_key = try(length(local.remote_states[local.remote_state_backend_key]), 0) > 0 ? local.remote_state_backend_key : "bypass"
4646

4747
outputs = local.remote_states[local.computed_remote_state_backend_key]

0 commit comments

Comments
 (0)