@pulumi/azuread
Version:
A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.
128 lines • 5.46 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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.DirectoryRoleAssignment = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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*
*
* ## 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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.appScopeId : undefined;
resourceInputs["directoryScopeId"] = state ? state.directoryScopeId : undefined;
resourceInputs["principalObjectId"] = state ? state.principalObjectId : undefined;
resourceInputs["roleId"] = state ? state.roleId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.principalObjectId === undefined) && !opts.urn) {
throw new Error("Missing required property 'principalObjectId'");
}
if ((!args || args.roleId === undefined) && !opts.urn) {
throw new Error("Missing required property 'roleId'");
}
resourceInputs["appScopeId"] = args ? args.appScopeId : undefined;
resourceInputs["directoryScopeId"] = args ? args.directoryScopeId : undefined;
resourceInputs["principalObjectId"] = args ? args.principalObjectId : undefined;
resourceInputs["roleId"] = args ? args.roleId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(DirectoryRoleAssignment.__pulumiType, name, resourceInputs, opts);
}
}
exports.DirectoryRoleAssignment = DirectoryRoleAssignment;
/** @internal */
DirectoryRoleAssignment.__pulumiType = 'azuread:index/directoryRoleAssignment:DirectoryRoleAssignment';
//# sourceMappingURL=directoryRoleAssignment.js.map