Quantcast
Channel: Terraform - HashiCorp Discuss
Viewing all articles
Browse latest Browse all 11357

Tranposing a Map of Maps

$
0
0

Hi,

I’ve got a map of Azure AD users (data.azuread_user) which looks like a consecutive bunch of these:

"XXXXX-XXXXX-XXXXX-XXXXX" = {
    "account_enabled" = true
    "display_name" = "Poppa Smurf"
    "id" = "XXXXX-XXXXX-XXXXX-XXXXX"
    "immutable_id" = ""
    "mail" = "poppa.smurf@company.com"
    "mail_nickname" = "poppa.smurf"
    "object_id" = "XXXXX-XXXXX-XXXXX-XXXXX"
    "onpremises_sam_account_name" = ""
    "onpremises_user_principal_name" = ""
    "usage_location" = "US"
    "user_principal_name" = "poppa.smurf@company.com"
  }    

Due to the way I generated it, via a for_each off the list of members on the all users group in Azure AD, the key is the UUID.

How can I transpose or otherwise munge the list so that the mail_nickname subvalue becomes the top level key instead? I’ve look at transpose and “for blah in blah” but can’t work out how to put either of those together to do the thing.

End result will hopefully be:

"poppa.smurf" = {
    "account_enabled" = true
    "display_name" = "Poppa Smurf"
    "id" = "XXXXX-XXXXX-XXXXX-XXXXX"
    "immutable_id" = ""
    "mail" = "poppa.smurf@company.com"
    "mail_nickname" = "poppa.smurf"
    "object_id" = "XXXXX-XXXXX-XXXXX-XXXXX"
    "onpremises_sam_account_name" = ""
    "onpremises_user_principal_name" = ""
    "usage_location" = "US"
    "user_principal_name" = "poppa.smurf@company.com"
  }  

Cheers,

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 11357

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>