Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform Import azurerm_role_assignment

I have to import some roles, in the documentation it states. The frist uid is easy to find, but what is the second one. When I look into the portal I see that the role is assigned on the resource itself, but can't find a trace of a uid. Can find the uid of the group what has the rights but ..

terraform import azurerm_role_assignment.example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000

So Bottom line, anybody has this working and willing to share some thoughts ?

like image 856
Harry-Sibelco Avatar asked Sep 07 '25 23:09

Harry-Sibelco


2 Answers

You can also use the Azure Resource Explorer portal to browse your resource definitions.

Use the tree view on the left to browse your resources; generally the structure's pretty intuitive.

To avoid clicking through, the URIs are pretty predictable too...

  • To see role assignments against a subscription substitute your subscription's GUID in the following URI: https://resources.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignments

  • To do the same for a resource group, substitute your subscription's GUID and resource group's name for the placeholder values in this URI: https://resources.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Authorization/roleAssignments

Note: If you paste in one of these URIs directly it takes a few moments for the right page to load / the page may refresh a few times, so if you don't see the page you'd expect, wait up to 10 seconds.

On this page, you'll see a JSON value, where the info you're after is under value > properties > id.

like image 96
JohnLBevan Avatar answered Sep 09 '25 23:09

JohnLBevan


You can use Azure CLI:

az role assignment list ...

https://learn.microsoft.com/en-us/cli/azure/role/assignment?view=azure-cli-latest#az-role-assignment-list

like image 22
silent Avatar answered Sep 09 '25 21:09

silent