1. Answers
  2. Building an Azure User Assigned Identity with Pulumi

How do I build an Azure authorization userassignedidentity with Pulumi?

In this guide, we will create an Azure User Assigned Identity using Pulumi. A User Assigned Identity is a managed identity that you can assign to multiple Azure resources. This type of identity is useful for scenarios where you need to share the same identity across multiple resources.

Key Points:

  1. Resource Group: All Azure resources are grouped in a resource group.
  2. User Assigned Identity: The managed identity that can be assigned to Azure resources.

Below is a Pulumi program written in TypeScript that accomplishes this:

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";

// Create an Azure Resource Group
const resourceGroup = new azure.resources.ResourceGroup("exampleResourceGroup", {
    location: "WestUS",
});

// Create a User Assigned Identity
const userAssignedIdentity = new azure.managedidentity.UserAssignedIdentity("exampleIdentity", {
    resourceGroupName: resourceGroup.name,
    location: resourceGroup.location,
});

export const identityId = userAssignedIdentity.id;
export const identityClientId = userAssignedIdentity.clientId;
export const identityPrincipalId = userAssignedIdentity.principalId;

Explanation:

  1. Resource Group: We start by creating a resource group in the specified location (“WestUS”).
  2. User Assigned Identity: We then create a User Assigned Identity within the resource group created above.

Summary:

In this guide, we created an Azure User Assigned Identity using Pulumi. We first set up a resource group, and then created the User Assigned Identity within that resource group. The outputs include the identity’s ID, client ID, and principal ID which can be used to assign this identity to other Azure resources.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up