UNPKG

@pulumi/azuread

Version:

A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.

226 lines • 10.4 kB
"use strict"; // *** 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.ServicePrincipal = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * Manages a service principal associated with an application 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: `Application.ReadWrite.OwnedBy` or `Application.ReadWrite.All` * * > When using the `Application.ReadWrite.OwnedBy` application role, the principal being used to run Terraform must be an owner of _both_ the linked application registration, _and_ the service principal being managed. * * When authenticated with a user principal, this resource may require one of the following directory roles: `Application Administrator` or `Global Administrator` * * ## Example Usage * * *Create a service principal for an application* * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuread from "@pulumi/azuread"; * * const current = azuread.getClientConfig({}); * const example = new azuread.Application("example", { * displayName: "example", * owners: [current.then(current => current.objectId)], * }); * const exampleServicePrincipal = new azuread.ServicePrincipal("example", { * clientId: example.clientId, * appRoleAssignmentRequired: false, * owners: [current.then(current => current.objectId)], * }); * ``` * * *Create a service principal for an enterprise application* * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuread from "@pulumi/azuread"; * * const current = azuread.getClientConfig({}); * const example = new azuread.Application("example", { * displayName: "example", * owners: [current.then(current => current.objectId)], * }); * const exampleServicePrincipal = new azuread.ServicePrincipal("example", { * clientId: example.clientId, * appRoleAssignmentRequired: false, * owners: [current.then(current => current.objectId)], * featureTags: [{ * enterprise: true, * gallery: true, * }], * }); * ``` * * *Manage a service principal for a first-party Microsoft application* * * ```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, * }); * ``` * * *Create a service principal for an application created from a gallery template* * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuread from "@pulumi/azuread"; * * const example = azuread.getApplicationTemplate({ * displayName: "Marketo", * }); * const exampleApplication = new azuread.Application("example", { * displayName: "example", * templateId: example.then(example => example.templateId), * }); * const exampleServicePrincipal = new azuread.ServicePrincipal("example", { * clientId: exampleApplication.clientId, * useExisting: true, * }); * ``` * * ## Import * * Service principals can be imported using their object ID, e.g. * * ```sh * $ pulumi import azuread:index/servicePrincipal:ServicePrincipal example /servicePrincipals/00000000-0000-0000-0000-000000000000 * ``` */ class ServicePrincipal extends pulumi.CustomResource { /** * Get an existing ServicePrincipal 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 ServicePrincipal(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'azuread:index/servicePrincipal:ServicePrincipal'; /** * Returns true if the given object is an instance of ServicePrincipal. 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'] === ServicePrincipal.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accountEnabled"] = state?.accountEnabled; resourceInputs["alternativeNames"] = state?.alternativeNames; resourceInputs["appRoleAssignmentRequired"] = state?.appRoleAssignmentRequired; resourceInputs["appRoleIds"] = state?.appRoleIds; resourceInputs["appRoles"] = state?.appRoles; resourceInputs["applicationTenantId"] = state?.applicationTenantId; resourceInputs["clientId"] = state?.clientId; resourceInputs["description"] = state?.description; resourceInputs["displayName"] = state?.displayName; resourceInputs["featureTags"] = state?.featureTags; resourceInputs["features"] = state?.features; resourceInputs["homepageUrl"] = state?.homepageUrl; resourceInputs["loginUrl"] = state?.loginUrl; resourceInputs["logoutUrl"] = state?.logoutUrl; resourceInputs["notes"] = state?.notes; resourceInputs["notificationEmailAddresses"] = state?.notificationEmailAddresses; resourceInputs["oauth2PermissionScopeIds"] = state?.oauth2PermissionScopeIds; resourceInputs["oauth2PermissionScopes"] = state?.oauth2PermissionScopes; resourceInputs["objectId"] = state?.objectId; resourceInputs["owners"] = state?.owners; resourceInputs["preferredSingleSignOnMode"] = state?.preferredSingleSignOnMode; resourceInputs["redirectUris"] = state?.redirectUris; resourceInputs["samlMetadataUrl"] = state?.samlMetadataUrl; resourceInputs["samlSingleSignOn"] = state?.samlSingleSignOn; resourceInputs["servicePrincipalNames"] = state?.servicePrincipalNames; resourceInputs["signInAudience"] = state?.signInAudience; resourceInputs["tags"] = state?.tags; resourceInputs["type"] = state?.type; resourceInputs["useExisting"] = state?.useExisting; } else { const args = argsOrState; if (args?.clientId === undefined && !opts.urn) { throw new Error("Missing required property 'clientId'"); } resourceInputs["accountEnabled"] = args?.accountEnabled; resourceInputs["alternativeNames"] = args?.alternativeNames; resourceInputs["appRoleAssignmentRequired"] = args?.appRoleAssignmentRequired; resourceInputs["clientId"] = args?.clientId; resourceInputs["description"] = args?.description; resourceInputs["featureTags"] = args?.featureTags; resourceInputs["features"] = args?.features; resourceInputs["loginUrl"] = args?.loginUrl; resourceInputs["notes"] = args?.notes; resourceInputs["notificationEmailAddresses"] = args?.notificationEmailAddresses; resourceInputs["owners"] = args?.owners; resourceInputs["preferredSingleSignOnMode"] = args?.preferredSingleSignOnMode; resourceInputs["samlSingleSignOn"] = args?.samlSingleSignOn; resourceInputs["tags"] = args?.tags; resourceInputs["useExisting"] = args?.useExisting; resourceInputs["appRoleIds"] = undefined /*out*/; resourceInputs["appRoles"] = undefined /*out*/; resourceInputs["applicationTenantId"] = undefined /*out*/; resourceInputs["displayName"] = undefined /*out*/; resourceInputs["homepageUrl"] = undefined /*out*/; resourceInputs["logoutUrl"] = undefined /*out*/; resourceInputs["oauth2PermissionScopeIds"] = undefined /*out*/; resourceInputs["oauth2PermissionScopes"] = undefined /*out*/; resourceInputs["objectId"] = undefined /*out*/; resourceInputs["redirectUris"] = undefined /*out*/; resourceInputs["samlMetadataUrl"] = undefined /*out*/; resourceInputs["servicePrincipalNames"] = undefined /*out*/; resourceInputs["signInAudience"] = undefined /*out*/; resourceInputs["type"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ServicePrincipal.__pulumiType, name, resourceInputs, opts); } } exports.ServicePrincipal = ServicePrincipal; //# sourceMappingURL=servicePrincipal.js.map