Skip to content

Commit

Permalink
Fix bug introduced in v1.3.0 by #57 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Oct 18, 2022
1 parent a7e87a4 commit 3c7ac8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions modules/remote-state/data_source.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
locals {
data_source_backends = ["remote", "s3"]
is_data_source_backend = contains(local.data_source_backends, local.backend_type)

remote_workspace = var.workspace != null ? var.workspace : local.workspace
ds_backend = contains(["remote", "s3"], local.backend_type) ? local.backend_type : "local"
ds_backend = local.is_data_source_backend ? local.backend_type : "local"
ds_workspace = local.ds_backend == "local" ? null : local.remote_workspace

ds_configurations = {
local = {
path = "${path.module}/dummy-remote-state.json"
}

remote = local.ds_backend == "remote" ? {
remote = local.ds_backend != "remote" ? null : {
organization = local.backend.organization

workspaces = {
name = local.remote_workspace
}
} : null
}

s3 = local.ds_backend == "s3" ? {
s3 = local.ds_backend != "s3" ? null : {
encrypt = local.backend.encrypt
bucket = local.backend.bucket
key = local.backend.key
Expand Down Expand Up @@ -69,7 +72,7 @@ locals {
profile = !coalesce(try(local.backend.privileged, null), var.privileged) && contains(keys(local.backend), "profile") ? local.backend.profile : null

workspace_key_prefix = local.workspace_key_prefix
} : null
}
} # ds_configurations


Expand Down
2 changes: 1 addition & 1 deletion modules/remote-state/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ locals {
static = local.backend
}

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

outputs = local.remote_states[local.computed_remote_state_backend_key]
Expand Down

0 comments on commit 3c7ac8f

Please sign in to comment.