@pulumi/azuread
Version:
A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.
173 lines • 7.23 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DirectoryRoleAssignment = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* Manages a single directory role assignment within Azure Active Directory.
*
* ## API Permissions
*
* The following API permissions are required in order to use this resource.
*
* When authenticated with a service principal, this resource requires one of the following application roles: `RoleManagement.ReadWrite.Directory` or `Directory.ReadWrite.All`
*
* When authenticated with a user principal, this resource requires one of the following directory roles: `Privileged Role Administrator` or `Global Administrator`
*
* ## Example Usage
*
* *Assignment for a built-in role*
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuread from "@pulumi/azuread";
*
* const example = azuread.getUser({
* userPrincipalName: "jdoe@example.com",
* });
* const exampleDirectoryRole = new azuread.DirectoryRole("example", {displayName: "Security administrator"});
* const exampleDirectoryRoleAssignment = new azuread.DirectoryRoleAssignment("example", {
* roleId: exampleDirectoryRole.templateId,
* principalObjectId: example.then(example => example.objectId),
* });
* ```
*
* > Note the use of the `templateId` attribute when referencing built-in roles.
*
* *Assignment for a custom role*
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuread from "@pulumi/azuread";
*
* const example = azuread.getUser({
* userPrincipalName: "jdoe@example.com",
* });
* const exampleCustomDirectoryRole = new azuread.CustomDirectoryRole("example", {
* displayName: "My Custom Role",
* enabled: true,
* version: "1.0",
* permissions: [{
* allowedResourceActions: [
* "microsoft.directory/applications/basic/update",
* "microsoft.directory/applications/standard/read",
* ],
* }],
* });
* const exampleDirectoryRoleAssignment = new azuread.DirectoryRoleAssignment("example", {
* roleId: exampleCustomDirectoryRole.objectId,
* principalObjectId: example.then(example => example.objectId),
* });
* ```
*
* *Scoped assignment for an application*
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuread from "@pulumi/azuread";
* import * as std from "@pulumi/std";
*
* const exampleDirectoryRole = new azuread.DirectoryRole("example", {displayName: "Cloud application administrator"});
* const exampleApplication = new azuread.Application("example", {displayName: "My Application"});
* const example = azuread.getUser({
* userPrincipalName: "jdoe@example.com",
* });
* const exampleDirectoryRoleAssignment = new azuread.DirectoryRoleAssignment("example", {
* roleId: exampleDirectoryRole.templateId,
* principalObjectId: example.then(example => example.objectId),
* directoryScopeId: std.format({
* input: "/%s",
* args: [exampleApplication.objectId],
* }).then(invoke => invoke.result),
* });
* ```
*
* > Note the use of the `templateId` attribute when referencing built-in roles.
*
* ## Import
*
* Directory role assignments can be imported using the ID of the assignment, e.g.
*
* ```sh
* $ pulumi import azuread:index/directoryRoleAssignment:DirectoryRoleAssignment example ePROZI_iKE653D_d6aoLHyr-lKgHI8ZGiIdz8CLVcng-1
* ```
*/
class DirectoryRoleAssignment extends pulumi.CustomResource {
/**
* Get an existing DirectoryRoleAssignment resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new DirectoryRoleAssignment(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'azuread:index/directoryRoleAssignment:DirectoryRoleAssignment';
/**
* Returns true if the given object is an instance of DirectoryRoleAssignment. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === DirectoryRoleAssignment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["appScopeId"] = state?.appScopeId;
resourceInputs["directoryScopeId"] = state?.directoryScopeId;
resourceInputs["principalObjectId"] = state?.principalObjectId;
resourceInputs["roleId"] = state?.roleId;
}
else {
const args = argsOrState;
if (args?.principalObjectId === undefined && !opts.urn) {
throw new Error("Missing required property 'principalObjectId'");
}
if (args?.roleId === undefined && !opts.urn) {
throw new Error("Missing required property 'roleId'");
}
resourceInputs["appScopeId"] = args?.appScopeId;
resourceInputs["directoryScopeId"] = args?.directoryScopeId;
resourceInputs["principalObjectId"] = args?.principalObjectId;
resourceInputs["roleId"] = args?.roleId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(DirectoryRoleAssignment.__pulumiType, name, resourceInputs, opts);
}
}
exports.DirectoryRoleAssignment = DirectoryRoleAssignment;
//# sourceMappingURL=directoryRoleAssignment.js.map