UNPKG

@pulumi/gcp

Version:

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

154 lines 6.85 kB
"use strict"; // *** 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.Project = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Allows creation and management of a Google Cloud Platform project. * * Projects created with this resource must be associated with an Organization. * See the [Organization documentation](https://cloud.google.com/resource-manager/docs/quickstarts) for more details. * * The user or service account that is running this provider when creating a `gcp.organizations.Project` * resource must have `roles/resourcemanager.projectCreator` on the specified organization. See the * [Access Control for Organizations Using IAM](https://cloud.google.com/resource-manager/docs/access-control-org) * doc for more information. * * > This resource reads the specified billing account on every pulumi up and plan operation so you must have permissions on the specified billing account. * * > It is recommended to use the `constraints/compute.skipDefaultNetworkCreation` [constraint](https://www.terraform.io/docs/providers/google/r/google_organization_policy.html) to remove the default network instead of setting `autoCreateNetwork` to false, when possible. * * > It may take a while for the attached tag bindings to be deleted after the project is scheduled to be deleted. * * To get more information about projects, see: * * * [API documentation](https://cloud.google.com/resource-manager/reference/rest/v1/projects) * * How-to Guides * * [Creating and managing projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects) * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myProject = new gcp.organizations.Project("my_project", { * name: "My Project", * projectId: "your-project-id", * orgId: "1234567", * }); * ``` * * To create a project under a specific folder * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const department1 = new gcp.organizations.Folder("department1", { * displayName: "Department 1", * parent: "organizations/1234567", * }); * const myProject_in_a_folder = new gcp.organizations.Project("my_project-in-a-folder", { * name: "My Project", * projectId: "your-project-id", * folderId: department1.name, * }); * ``` * * To create a project with a tag * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myProject = new gcp.organizations.Project("my_project", { * name: "My Project", * projectId: "your-project-id", * orgId: "1234567", * tags: { * "1234567/env": "staging", * }, * }); * ``` * * ## Import * * Projects can be imported using the `project_id`, e.g. * * * `{{project_id}}` * * When using the `pulumi import` command, Projects can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:organizations/project:Project default {{project_id}} * ``` */ class Project extends pulumi.CustomResource { /** * Get an existing Project 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 Project(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Project. 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'] === Project.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["autoCreateNetwork"] = state ? state.autoCreateNetwork : undefined; resourceInputs["billingAccount"] = state ? state.billingAccount : undefined; resourceInputs["deletionPolicy"] = state ? state.deletionPolicy : undefined; resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined; resourceInputs["folderId"] = state ? state.folderId : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["number"] = state ? state.number : undefined; resourceInputs["orgId"] = state ? state.orgId : undefined; resourceInputs["projectId"] = state ? state.projectId : undefined; resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined; resourceInputs["tags"] = state ? state.tags : undefined; } else { const args = argsOrState; resourceInputs["autoCreateNetwork"] = args ? args.autoCreateNetwork : undefined; resourceInputs["billingAccount"] = args ? args.billingAccount : undefined; resourceInputs["deletionPolicy"] = args ? args.deletionPolicy : undefined; resourceInputs["folderId"] = args ? args.folderId : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["orgId"] = args ? args.orgId : undefined; resourceInputs["projectId"] = args ? args.projectId : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["number"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Project.__pulumiType, name, resourceInputs, opts); } } exports.Project = Project; /** @internal */ Project.__pulumiType = 'gcp:organizations/project:Project'; //# sourceMappingURL=project.js.map