From 5119d843f1dd07ce3203e19a2be65cd1bc185b60 Mon Sep 17 00:00:00 2001 From: 3u13r Date: Thu, 3 Aug 2023 13:22:26 +0200 Subject: [PATCH] terraform: fix uami parsing (#2155) --- cli/internal/terraform/terraform/azure/main.tf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cli/internal/terraform/terraform/azure/main.tf b/cli/internal/terraform/terraform/azure/main.tf index d5dff7e42..71c42ae1b 100644 --- a/cli/internal/terraform/terraform/azure/main.tf +++ b/cli/internal/terraform/terraform/azure/main.tf @@ -38,8 +38,11 @@ locals { // wildcard_lb_dns_name is the DNS name of the load balancer with a wildcard for the name. // example: given "name-1234567890.location.cloudapp.azure.com" it will return "*.location.cloudapp.azure.com" wildcard_lb_dns_name = replace(data.azurerm_public_ip.loadbalancer_ip.fqdn, "/^[^.]*\\./", "*.") - uai_resource_group = element(split("/", var.user_assigned_identity), 4) // deduce from format /$ID/resourceGroups/$RG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$NAME" - uai_name = element(split("/", var.user_assigned_identity), length(split("/", var.user_assigned_identity)) - 1) // deduce as above + // deduce from format (subscriptions)/$ID/resourceGroups/$RG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$NAME" + // move from the right as to ignore the optional prefixes + uai_resource_group = element(split("/", var.user_assigned_identity), length(split("/", var.user_assigned_identity)) - 5) + // deduce as above + uai_name = element(split("/", var.user_assigned_identity), length(split("/", var.user_assigned_identity)) - 1) } resource "random_id" "uid" {