UNPKG

@pulumi/gcp

Version:

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

266 lines • 9.57 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")); /** * Defines an organization policy which is used to specify constraints for configurations of Google Cloud resources. * * To get more information about Policy, see: * * * [API documentation](https://docs.cloud.google.com/resource-manager/docs/reference/orgpolicy/rest/v2/organizations.policies) * * How-to Guides * * [Official Documentation](https://docs.cloud.google.com/resource-manager/docs/organization-policy/creating-managing-custom-constraints) * * [Supported Services](https://docs.cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services) * * ## Example Usage * * ### Org Policy Policy Enforce * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const basic = new gcp.organizations.Project("basic", { * projectId: "id", * name: "id", * orgId: "123456789", * deletionPolicy: "DELETE", * }); * const primary = new gcp.orgpolicy.Policy("primary", { * name: pulumi.interpolate`projects/${basic.projectId}/policies/iam.disableServiceAccountKeyUpload`, * parent: pulumi.interpolate`projects/${basic.projectId}`, * spec: { * rules: [{ * enforce: "FALSE", * }], * }, * }); * ``` * ### Org Policy Policy Folder * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const basic = new gcp.organizations.Folder("basic", { * parent: "organizations/123456789", * displayName: "folder", * deletionProtection: false, * }); * const primary = new gcp.orgpolicy.Policy("primary", { * name: pulumi.interpolate`${basic.name}/policies/gcp.resourceLocations`, * parent: basic.name, * spec: { * inheritFromParent: true, * rules: [{ * denyAll: "TRUE", * }], * }, * }); * ``` * ### Org Policy Policy Organization * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const primary = new gcp.orgpolicy.Policy("primary", { * name: "organizations/123456789/policies/gcp.detailedAuditLoggingMode", * parent: "organizations/123456789", * spec: { * reset: true, * }, * }); * ``` * ### Org Policy Policy Project * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const basic = new gcp.organizations.Project("basic", { * projectId: "id", * name: "id", * orgId: "123456789", * deletionPolicy: "DELETE", * }); * const primary = new gcp.orgpolicy.Policy("primary", { * name: pulumi.interpolate`projects/${basic.projectId}/policies/gcp.resourceLocations`, * parent: pulumi.interpolate`projects/${basic.projectId}`, * spec: { * rules: [ * { * condition: { * description: "A sample condition for the policy", * expression: "resource.matchTagId('tagKeys/123', 'tagValues/345')", * location: "sample-location.log", * title: "sample-condition", * }, * values: { * allowedValues: ["projects/allowed-project"], * deniedValues: ["projects/denied-project"], * }, * }, * { * allowAll: "TRUE", * }, * ], * }, * }); * ``` * ### Org Policy Policy Dry Run Spec * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const constraint = new gcp.orgpolicy.CustomConstraint("constraint", { * name: "custom.disableGkeAutoUpgrade_97962", * parent: "organizations/123456789", * displayName: "Disable GKE auto upgrade", * description: "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.", * actionType: "ALLOW", * condition: "resource.management.autoUpgrade == false", * methodTypes: ["CREATE"], * resourceTypes: ["container.googleapis.com/NodePool"], * }); * const primary = new gcp.orgpolicy.Policy("primary", { * name: pulumi.interpolate`organizations/123456789/policies/${constraint.name}`, * parent: "organizations/123456789", * spec: { * rules: [{ * enforce: "FALSE", * }], * }, * dryRunSpec: { * inheritFromParent: false, * reset: false, * rules: [{ * enforce: "FALSE", * }], * }, * }); * ``` * ### Org Policy Policy Parameters Enforce * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const basic = new gcp.organizations.Project("basic", { * projectId: "id", * name: "id", * orgId: "123456789", * deletionPolicy: "DELETE", * }); * const primary = new gcp.orgpolicy.Policy("primary", { * name: pulumi.interpolate`projects/${basic.name}/policies/compute.managed.restrictDiskCreation`, * parent: pulumi.interpolate`projects/${basic.name}`, * spec: { * rules: [{ * enforce: "TRUE", * parameters: JSON.stringify({ * isSizeLimitCheck: true, * allowedDiskTypes: [ * "pd-ssd", * "pd-standard", * ], * }), * }], * }, * }); * ``` * * ## Import * * Policy can be imported using any of these accepted formats: * * * `{{parent}}/policies/{{name}}` * * When using the `pulumi import` command, Policy can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:orgpolicy/policy:Policy default {{parent}}/policies/{{name}} * ``` */ 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:orgpolicy/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["deletionPolicy"] = state?.deletionPolicy; resourceInputs["dryRunSpec"] = state?.dryRunSpec; resourceInputs["etag"] = state?.etag; resourceInputs["name"] = state?.name; resourceInputs["parent"] = state?.parent; resourceInputs["spec"] = state?.spec; } else { const args = argsOrState; if (args?.parent === undefined && !opts.urn) { throw new Error("Missing required property 'parent'"); } resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["dryRunSpec"] = args?.dryRunSpec; resourceInputs["name"] = args?.name; resourceInputs["parent"] = args?.parent; resourceInputs["spec"] = args?.spec; resourceInputs["etag"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Policy.__pulumiType, name, resourceInputs, opts); } } exports.Policy = Policy; //# sourceMappingURL=policy.js.map