Skip to content

Commit 325d23c

Browse files
authored
[remote-state] bugfix: Handle case where defaults is incompatible type (#49)
1 parent d7b98c5 commit 325d23c

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

.github/renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
":preserveSemverRanges"
55
],
66
"labels": ["auto-update"],
7+
"dependencyDashboardAutoclose": true,
78
"enabledManagers": ["terraform"],
89
"terraform": {
910
"ignorePaths": ["**/context.tf", "examples/**"]
1011
}
1112
}
12-

examples/remote-state/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ module "remote_state_using_stack" {
44
component = "test/test-component-override"
55
stack = "tenant1-ue2-dev"
66

7+
# Verify that a default output not matching the real output does not cause a Terraform error
8+
defaults = {
9+
val1 = ["default-list"]
10+
val2 = "default-value"
11+
}
12+
13+
714
context = module.this.context
815
}
916

modules/remote-state/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ locals {
3636
static = [{ outputs = local.backend }]
3737
}
3838

39-
remote_state_backend_key = var.bypass ? "bypass" : local.backend_type
40-
outputs = try(length(local.remote_state_backend_key), 0) > 0 ? local.remote_states[local.remote_state_backend_key][0].outputs : var.defaults
39+
remote_state_backend_key = var.bypass ? "bypass" : local.backend_type
40+
computed_remote_state_backend_key = try(length(local.remote_states[local.remote_state_backend_key]), 0) > 0 ? local.remote_state_backend_key : "bypass"
41+
42+
outputs = local.remote_states[local.computed_remote_state_backend_key][0].outputs
4143
}

0 commit comments

Comments
 (0)