Skip to content

Commit

Permalink
Merge pull request #3 from azurerm/fix-coalesce-type
Browse files Browse the repository at this point in the history
fix: coalesce return was not working using display name
  • Loading branch information
vmisson authored Jul 18, 2023
2 parents d26a795 + 5fbd87a commit 403c78d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "azure_location" {
source = "../"
source = "../"
location = "West Europe"
}

Expand All @@ -15,7 +15,7 @@ output "location" {
# }

module "azure_fake_location" {
source = "../"
source = "../"
location = "Test Europe"
}

Expand Down
10 changes: 6 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ locals {
}
}

location = coalesce(
lookup(local.locations_name, var.location, null),
lookup(local.locations_display_name, var.location, "none")
)
lookup_name = lookup(local.locations_name, var.location, null)
lookup_display_name = lookup(local.locations_display_name, var.location, null)
location = try(coalesce(
local.lookup_name,
local.lookup_display_name
), "none")
}

0 comments on commit 403c78d

Please sign in to comment.