nolwww
nolwww

Reputation: 1745

Assign role to user using Service principal

I have created some resources in Azure using Terraform and a Service principal:

Now, I need to create a virtual Gateway from this resource group and virtual network, but using a personal Azure account in the same Organization.

How can I add my user email as a Administrator to this resource group, from Terraform, using the Service Principal credentials?

Upvotes: 0

Views: 673

Answers (1)

Andriy Bilous
Andriy Bilous

Reputation: 2522

You can use Terraform resource azurerm_role_assignment to add Owner permissions for your user to this resource group.

Example:

resource "azurerm_resource_group" "this" {
  name     = "example"
  location = "West Europe"
}

resource "azurerm_role_assignment" "this" {
  scope = azurerm_resource_group.this.id
  role_definition_name = "Owner"
  principal_id = "<Your user object id>"
}

Upvotes: 1

Related Questions