Skip to content

Commit

Permalink
[remote-state] bugfix: Handle case where defaults is incompatible type (
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Jun 2, 2022
1 parent d7b98c5 commit 325d23c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
":preserveSemverRanges"
],
"labels": ["auto-update"],
"dependencyDashboardAutoclose": true,
"enabledManagers": ["terraform"],
"terraform": {
"ignorePaths": ["**/context.tf", "examples/**"]
}
}

7 changes: 7 additions & 0 deletions examples/remote-state/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ module "remote_state_using_stack" {
component = "test/test-component-override"
stack = "tenant1-ue2-dev"

# Verify that a default output not matching the real output does not cause a Terraform error
defaults = {
val1 = ["default-list"]
val2 = "default-value"
}


context = module.this.context
}

Expand Down
6 changes: 4 additions & 2 deletions modules/remote-state/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ locals {
static = [{ outputs = local.backend }]
}

remote_state_backend_key = var.bypass ? "bypass" : local.backend_type
outputs = try(length(local.remote_state_backend_key), 0) > 0 ? local.remote_states[local.remote_state_backend_key][0].outputs : var.defaults
remote_state_backend_key = var.bypass ? "bypass" : 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][0].outputs
}

0 comments on commit 325d23c

Please sign in to comment.