@pulumi/azuread
Version:
A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.
168 lines • 7.5 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServicePrincipalDelegatedPermissionGrant = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Manages a delegated permission grant for a service principal, on behalf of a single user, or all users.
*
* ## API Permissions
*
* The following API permissions are required in order to use this resource.
*
* When authenticated with a service principal, this resource requires the following application role: `Directory.ReadWrite.All`
*
* When authenticated with a user principal, this resource requires one the following directory role: `Global Administrator`
*
* ## Example Usage
*
* *Delegated permission grant for all users*
*
* ```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.oauth2PermissionScopeIds.openid,
* type: "Scope",
* },
* {
* id: msgraph.oauth2PermissionScopeIds["User.Read"],
* type: "Scope",
* },
* ],
* }],
* });
* const exampleServicePrincipal = new azuread.ServicePrincipal("example", {clientId: example.clientId});
* const exampleServicePrincipalDelegatedPermissionGrant = new azuread.ServicePrincipalDelegatedPermissionGrant("example", {
* servicePrincipalObjectId: exampleServicePrincipal.objectId,
* resourceServicePrincipalObjectId: msgraph.objectId,
* claimValues: [
* "openid",
* "User.Read.All",
* ],
* });
* ```
*
* *Delegated permission grant for a single user*
*
* ```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.oauth2PermissionScopeIds.openid,
* type: "Scope",
* },
* {
* id: msgraph.oauth2PermissionScopeIds["User.Read"],
* type: "Scope",
* },
* ],
* }],
* });
* const exampleServicePrincipal = new azuread.ServicePrincipal("example", {clientId: example.clientId});
* const exampleUser = new azuread.User("example", {
* displayName: "J. Doe",
* userPrincipalName: "jdoe@example.com",
* mailNickname: "jdoe",
* password: "SecretP@sswd99!",
* });
* const exampleServicePrincipalDelegatedPermissionGrant = new azuread.ServicePrincipalDelegatedPermissionGrant("example", {
* servicePrincipalObjectId: exampleServicePrincipal.objectId,
* resourceServicePrincipalObjectId: msgraph.objectId,
* claimValues: [
* "openid",
* "User.Read.All",
* ],
* userObjectId: exampleUser.objectId,
* });
* ```
*
* ## Import
*
* Delegated permission grants can be imported using their ID, e.g.
*
* ```sh
* $ pulumi import azuread:index/servicePrincipalDelegatedPermissionGrant:ServicePrincipalDelegatedPermissionGrant example aaBBcDDeFG6h5JKLMN2PQrrssTTUUvWWxxxxxyyyzzz
* ```
*/
class ServicePrincipalDelegatedPermissionGrant extends pulumi.CustomResource {
/**
* Get an existing ServicePrincipalDelegatedPermissionGrant 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 ServicePrincipalDelegatedPermissionGrant(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of ServicePrincipalDelegatedPermissionGrant. 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'] === ServicePrincipalDelegatedPermissionGrant.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["claimValues"] = state ? state.claimValues : undefined;
resourceInputs["resourceServicePrincipalObjectId"] = state ? state.resourceServicePrincipalObjectId : undefined;
resourceInputs["servicePrincipalObjectId"] = state ? state.servicePrincipalObjectId : undefined;
resourceInputs["userObjectId"] = state ? state.userObjectId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.claimValues === undefined) && !opts.urn) {
throw new Error("Missing required property 'claimValues'");
}
if ((!args || args.resourceServicePrincipalObjectId === undefined) && !opts.urn) {
throw new Error("Missing required property 'resourceServicePrincipalObjectId'");
}
if ((!args || args.servicePrincipalObjectId === undefined) && !opts.urn) {
throw new Error("Missing required property 'servicePrincipalObjectId'");
}
resourceInputs["claimValues"] = args ? args.claimValues : undefined;
resourceInputs["resourceServicePrincipalObjectId"] = args ? args.resourceServicePrincipalObjectId : undefined;
resourceInputs["servicePrincipalObjectId"] = args ? args.servicePrincipalObjectId : undefined;
resourceInputs["userObjectId"] = args ? args.userObjectId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ServicePrincipalDelegatedPermissionGrant.__pulumiType, name, resourceInputs, opts);
}
}
exports.ServicePrincipalDelegatedPermissionGrant = ServicePrincipalDelegatedPermissionGrant;
/** @internal */
ServicePrincipalDelegatedPermissionGrant.__pulumiType = 'azuread:index/servicePrincipalDelegatedPermissionGrant:ServicePrincipalDelegatedPermissionGrant';
//# sourceMappingURL=servicePrincipalDelegatedPermissionGrant.js.map