UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

186 lines • 7.38 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.Policy = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Allows management of Organization Policies for a Google Cloud Organization. * * > **Warning:** This resource has been superseded by `gcp.orgpolicy.Policy`. `gcp.orgpolicy.Policy` uses Organization Policy API V2 instead of Cloud Resource Manager API V1 and it supports additional features such as tags and conditions. * * To get more information about Organization Policies, see: * * * [API documentation](https://docs.cloud.google.com/resource-manager/reference/rest/v1/organizations/setOrgPolicy) * * How-to Guides * * [Introduction to the Organization Policy Service](https://docs.cloud.google.com/resource-manager/docs/organization-policy/overview) * * ## Example Usage * * To set policy with a [boolean constraint](https://docs.cloud.google.com/resource-manager/docs/organization-policy/quickstart-boolean-constraints): * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const serialPortPolicy = new gcp.organizations.Policy("serial_port_policy", { * orgId: "123456789", * constraint: "compute.disableSerialPortAccess", * booleanPolicy: { * enforced: true, * }, * }); * ``` * * To set a policy with a [list constraint](https://docs.cloud.google.com/resource-manager/docs/organization-policy/quickstart-list-constraints): * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const servicesPolicy = new gcp.organizations.Policy("services_policy", { * orgId: "123456789", * constraint: "serviceuser.services", * listPolicy: { * allow: { * all: true, * }, * }, * }); * ``` * * Or to deny some services, use the following instead: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const servicesPolicy = new gcp.organizations.Policy("services_policy", { * orgId: "123456789", * constraint: "serviceuser.services", * listPolicy: { * suggestedValue: "compute.googleapis.com", * deny: { * values: ["cloudresourcemanager.googleapis.com"], * }, * }, * }); * ``` * * To restore the default organization policy, use the following instead: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const servicesPolicy = new gcp.organizations.Policy("services_policy", { * orgId: "123456789", * constraint: "serviceuser.services", * restorePolicy: { * "default": true, * }, * }); * ``` * * ## Import * * Organization Policies can be imported using the `orgId` and the `constraint`, e.g. * * * `{{org_id}}/constraints/{{constraint}}` * * When using the `pulumi import` command, Organization Policies can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:organizations/policy:Policy default {{org_id}}/constraints/{{constraint}} * ``` * * It is all right if the constraint contains a slash, as in the example above. */ class Policy extends pulumi.CustomResource { /** * Get an existing Policy 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 Policy(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:organizations/policy:Policy'; /** * Returns true if the given object is an instance of Policy. 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'] === Policy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["booleanPolicy"] = state?.booleanPolicy; resourceInputs["constraint"] = state?.constraint; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["etag"] = state?.etag; resourceInputs["listPolicy"] = state?.listPolicy; resourceInputs["orgId"] = state?.orgId; resourceInputs["restorePolicy"] = state?.restorePolicy; resourceInputs["updateTime"] = state?.updateTime; resourceInputs["version"] = state?.version; } else { const args = argsOrState; if (args?.constraint === undefined && !opts.urn) { throw new Error("Missing required property 'constraint'"); } if (args?.orgId === undefined && !opts.urn) { throw new Error("Missing required property 'orgId'"); } resourceInputs["booleanPolicy"] = args?.booleanPolicy; resourceInputs["constraint"] = args?.constraint; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["listPolicy"] = args?.listPolicy; resourceInputs["orgId"] = args?.orgId; resourceInputs["restorePolicy"] = args?.restorePolicy; resourceInputs["version"] = args?.version; resourceInputs["etag"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Policy.__pulumiType, name, resourceInputs, opts); } } exports.Policy = Policy; //# sourceMappingURL=policy.js.map