Skip to content

Commit 5150181

Browse files
Update remote-state module (#41)
* Update `remote-state` module * Auto Format Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
1 parent 46de8a0 commit 5150181

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

modules/remote-state/main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ locals {
1212
remote_state_backend_type = try(local.config.remote_state_backend_type, "")
1313
backend_type = coalesce(local.remote_state_backend_type, local.config.backend_type)
1414

15-
remote_state_backend = try(local.config.remote_state_backend, null) != null ? local.config.remote_state_backend : null
16-
backend = local.remote_state_backend != null ? local.remote_state_backend : local.config.backend
15+
# If `config.remote_state_backend` is not declared in YAML config, the default value will be an empty map `{}`
16+
backend_config_key = try(local.config.remote_state_backend, null) != null && try(length(local.config.remote_state_backend), 0) > 0 ? "remote_state_backend" : "backend"
17+
18+
# This is used because the `?` operator in some instances (depending on the condition) changes the types of all items of the map to all `strings`
19+
backend_configs = {
20+
backend = local.config.backend
21+
remote_state_backend = local.config.remote_state_backend
22+
}
23+
24+
backend = local.backend_configs[local.backend_config_key]
1725

1826
workspace = local.config.workspace
1927
workspace_key_prefix = lookup(local.backend, "workspace_key_prefix", null)

0 commit comments

Comments
 (0)