@pulumi/azuread
Version:
A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.
187 lines • 8.51 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.AppRoleAssignment = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* Manages an app role assignment for a group, user or service principal. Can be used to grant admin consent for application permissions.
*
* ## 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: `AppRoleAssignment.ReadWrite.All` and `Application.Read.All`, or `AppRoleAssignment.ReadWrite.All` and `Directory.Read.All`, or `Application.ReadWrite.All`, or `Directory.ReadWrite.All`
*
* When authenticated with a user principal, this resource requires one of the following directory roles: `Application Administrator` or `Global Administrator`
*
* ## Example Usage
*
* *App role assignment for accessing Microsoft Graph*
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuread from "@pulumi/azuread";
*
* const wellKnown = azuread.getApplicationPublishedAppIds({});
* const msgraph = new azuread.ServicePrincipal("msgraph", {
* clientId: wellKnown.then(wellKnown => wellKnown.result?.microsoftGraph),
* useExisting: true,
* });
* const example = new azuread.Application("example", {
* displayName: "example",
* requiredResourceAccesses: [{
* resourceAppId: wellKnown.then(wellKnown => wellKnown.result?.microsoftGraph),
* resourceAccesses: [
* {
* id: msgraph.appRoleIds["User.Read.All"],
* type: "Role",
* },
* {
* id: msgraph.oauth2PermissionScopeIds["User.ReadWrite"],
* type: "Scope",
* },
* ],
* }],
* });
* const exampleServicePrincipal = new azuread.ServicePrincipal("example", {clientId: example.clientId});
* const exampleAppRoleAssignment = new azuread.AppRoleAssignment("example", {
* appRoleId: msgraph.appRoleIds["User.Read.All"],
* principalObjectId: exampleServicePrincipal.objectId,
* resourceObjectId: msgraph.objectId,
* });
* ```
*
* *App role assignment for internal application*
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuread from "@pulumi/azuread";
*
* const internal = new azuread.Application("internal", {
* displayName: "internal",
* appRoles: [{
* allowedMemberTypes: ["Application"],
* description: "Apps can query the database",
* displayName: "Query",
* enabled: true,
* id: "00000000-0000-0000-0000-111111111111",
* value: "Query.All",
* }],
* });
* const internalServicePrincipal = new azuread.ServicePrincipal("internal", {clientId: internal.clientId});
* const example = new azuread.Application("example", {
* displayName: "example",
* requiredResourceAccesses: [{
* resourceAppId: internal.clientId,
* resourceAccesses: [{
* id: internalServicePrincipal.appRoleIds["Query.All"],
* type: "Role",
* }],
* }],
* });
* const exampleServicePrincipal = new azuread.ServicePrincipal("example", {clientId: example.clientId});
* const exampleAppRoleAssignment = new azuread.AppRoleAssignment("example", {
* appRoleId: internalServicePrincipal.appRoleIds["Query.All"],
* principalObjectId: exampleServicePrincipal.objectId,
* resourceObjectId: internalServicePrincipal.objectId,
* });
* ```
*
* *Assign a user and group to an internal application*
*
* ## Import
*
* App role assignments can be imported using the object ID of the service principal representing the resource and the ID of the app role assignment (note: _not_ the ID of the app role), e.g.
*
* ```sh
* $ pulumi import azuread:index/appRoleAssignment:AppRoleAssignment example /servicePrincipals/00000000-0000-0000-0000-000000000000/appRoleAssignedTo/aaBBcDDeFG6h5JKLMN2PQrrssTTUUvWWxxxxxyyyzzz
* ```
*
* > This ID format is unique to Terraform and is composed of the Resource Service Principal Object ID and the ID of the App Role Assignment in the format `/servicePrincipals/{ResourcePrincipalID}/appRoleAssignedTo/{AppRoleAssignmentID}`.
*/
class AppRoleAssignment extends pulumi.CustomResource {
/**
* Get an existing AppRoleAssignment 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 AppRoleAssignment(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'azuread:index/appRoleAssignment:AppRoleAssignment';
/**
* Returns true if the given object is an instance of AppRoleAssignment. 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'] === AppRoleAssignment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["appRoleId"] = state?.appRoleId;
resourceInputs["principalDisplayName"] = state?.principalDisplayName;
resourceInputs["principalObjectId"] = state?.principalObjectId;
resourceInputs["principalType"] = state?.principalType;
resourceInputs["resourceDisplayName"] = state?.resourceDisplayName;
resourceInputs["resourceObjectId"] = state?.resourceObjectId;
}
else {
const args = argsOrState;
if (args?.appRoleId === undefined && !opts.urn) {
throw new Error("Missing required property 'appRoleId'");
}
if (args?.principalObjectId === undefined && !opts.urn) {
throw new Error("Missing required property 'principalObjectId'");
}
if (args?.resourceObjectId === undefined && !opts.urn) {
throw new Error("Missing required property 'resourceObjectId'");
}
resourceInputs["appRoleId"] = args?.appRoleId;
resourceInputs["principalObjectId"] = args?.principalObjectId;
resourceInputs["resourceObjectId"] = args?.resourceObjectId;
resourceInputs["principalDisplayName"] = undefined /*out*/;
resourceInputs["principalType"] = undefined /*out*/;
resourceInputs["resourceDisplayName"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(AppRoleAssignment.__pulumiType, name, resourceInputs, opts);
}
}
exports.AppRoleAssignment = AppRoleAssignment;
//# sourceMappingURL=appRoleAssignment.js.map