UNPKG

@pulumi/gcp

Version:

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

258 lines • 12.2 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.Function = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Creates a new Cloud Function. For more information see: * * * [API documentation](https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions) * * How-to Guides * * [Official Documentation](https://cloud.google.com/functions/docs) * * > **Warning:** As of November 1, 2019, newly created Functions are * private-by-default and will require [appropriate IAM permissions](https://cloud.google.com/functions/docs/reference/iam/roles) * to be invoked. See below examples for how to set up the appropriate permissions, * or view the [Cloud Functions IAM resources](https://www.terraform.io/docs/providers/google/r/cloudfunctions_cloud_function_iam.html) * for Cloud Functions. * * ## Example Usage * * ### Public Function * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const bucket = new gcp.storage.Bucket("bucket", { * name: "test-bucket", * location: "US", * }); * const archive = new gcp.storage.BucketObject("archive", { * name: "index.zip", * bucket: bucket.name, * source: new pulumi.asset.FileAsset("./path/to/zip/file/which/contains/code"), * }); * const _function = new gcp.cloudfunctions.Function("function", { * name: "function-test", * description: "My function", * runtime: "nodejs20", * availableMemoryMb: 128, * sourceArchiveBucket: bucket.name, * sourceArchiveObject: archive.name, * triggerHttp: true, * entryPoint: "helloGET", * }); * // IAM entry for all users to invoke the function * const invoker = new gcp.cloudfunctions.FunctionIamMember("invoker", { * project: _function.project, * region: _function.region, * cloudFunction: _function.name, * role: "roles/cloudfunctions.invoker", * member: "allUsers", * }); * ``` * * ### Single User * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const bucket = new gcp.storage.Bucket("bucket", { * name: "test-bucket", * location: "US", * }); * const archive = new gcp.storage.BucketObject("archive", { * name: "index.zip", * bucket: bucket.name, * source: new pulumi.asset.FileAsset("./path/to/zip/file/which/contains/code"), * }); * const _function = new gcp.cloudfunctions.Function("function", { * name: "function-test", * description: "My function", * runtime: "nodejs20", * availableMemoryMb: 128, * sourceArchiveBucket: bucket.name, * sourceArchiveObject: archive.name, * triggerHttp: true, * httpsTriggerSecurityLevel: "SECURE_ALWAYS", * timeout: 60, * entryPoint: "helloGET", * labels: { * "my-label": "my-label-value", * }, * environmentVariables: { * MY_ENV_VAR: "my-env-var-value", * }, * }); * // IAM entry for a single user to invoke the function * const invoker = new gcp.cloudfunctions.FunctionIamMember("invoker", { * project: _function.project, * region: _function.region, * cloudFunction: _function.name, * role: "roles/cloudfunctions.invoker", * member: "user:myFunctionInvoker@example.com", * }); * ``` * * ## Import * * Functions can be imported using the `name` or `{{project}}/{{region}}/name`, e.g. * * * `{{project}}/{{region}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, Functions can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:cloudfunctions/function:Function default {{project}}/{{region}}/{{name}} * $ pulumi import gcp:cloudfunctions/function:Function default {{name}} * ``` */ class Function extends pulumi.CustomResource { /** * Get an existing Function 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 Function(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:cloudfunctions/function:Function'; /** * Returns true if the given object is an instance of Function. 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'] === Function.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["automaticUpdatePolicy"] = state?.automaticUpdatePolicy; resourceInputs["availableMemoryMb"] = state?.availableMemoryMb; resourceInputs["buildEnvironmentVariables"] = state?.buildEnvironmentVariables; resourceInputs["buildServiceAccount"] = state?.buildServiceAccount; resourceInputs["buildWorkerPool"] = state?.buildWorkerPool; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["description"] = state?.description; resourceInputs["dockerRegistry"] = state?.dockerRegistry; resourceInputs["dockerRepository"] = state?.dockerRepository; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["entryPoint"] = state?.entryPoint; resourceInputs["environmentVariables"] = state?.environmentVariables; resourceInputs["eventTrigger"] = state?.eventTrigger; resourceInputs["httpsTriggerSecurityLevel"] = state?.httpsTriggerSecurityLevel; resourceInputs["httpsTriggerUrl"] = state?.httpsTriggerUrl; resourceInputs["ingressSettings"] = state?.ingressSettings; resourceInputs["kmsKeyName"] = state?.kmsKeyName; resourceInputs["labels"] = state?.labels; resourceInputs["maxInstances"] = state?.maxInstances; resourceInputs["minInstances"] = state?.minInstances; resourceInputs["name"] = state?.name; resourceInputs["onDeployUpdatePolicy"] = state?.onDeployUpdatePolicy; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["region"] = state?.region; resourceInputs["runtime"] = state?.runtime; resourceInputs["secretEnvironmentVariables"] = state?.secretEnvironmentVariables; resourceInputs["secretVolumes"] = state?.secretVolumes; resourceInputs["serviceAccountEmail"] = state?.serviceAccountEmail; resourceInputs["sourceArchiveBucket"] = state?.sourceArchiveBucket; resourceInputs["sourceArchiveObject"] = state?.sourceArchiveObject; resourceInputs["sourceRepository"] = state?.sourceRepository; resourceInputs["status"] = state?.status; resourceInputs["timeout"] = state?.timeout; resourceInputs["triggerHttp"] = state?.triggerHttp; resourceInputs["versionId"] = state?.versionId; resourceInputs["vpcConnector"] = state?.vpcConnector; resourceInputs["vpcConnectorEgressSettings"] = state?.vpcConnectorEgressSettings; } else { const args = argsOrState; if (args?.runtime === undefined && !opts.urn) { throw new Error("Missing required property 'runtime'"); } resourceInputs["automaticUpdatePolicy"] = args?.automaticUpdatePolicy; resourceInputs["availableMemoryMb"] = args?.availableMemoryMb; resourceInputs["buildEnvironmentVariables"] = args?.buildEnvironmentVariables; resourceInputs["buildServiceAccount"] = args?.buildServiceAccount; resourceInputs["buildWorkerPool"] = args?.buildWorkerPool; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["description"] = args?.description; resourceInputs["dockerRegistry"] = args?.dockerRegistry; resourceInputs["dockerRepository"] = args?.dockerRepository; resourceInputs["entryPoint"] = args?.entryPoint; resourceInputs["environmentVariables"] = args?.environmentVariables; resourceInputs["eventTrigger"] = args?.eventTrigger; resourceInputs["httpsTriggerSecurityLevel"] = args?.httpsTriggerSecurityLevel; resourceInputs["httpsTriggerUrl"] = args?.httpsTriggerUrl; resourceInputs["ingressSettings"] = args?.ingressSettings; resourceInputs["kmsKeyName"] = args?.kmsKeyName; resourceInputs["labels"] = args?.labels; resourceInputs["maxInstances"] = args?.maxInstances; resourceInputs["minInstances"] = args?.minInstances; resourceInputs["name"] = args?.name; resourceInputs["onDeployUpdatePolicy"] = args?.onDeployUpdatePolicy; resourceInputs["project"] = args?.project; resourceInputs["region"] = args?.region; resourceInputs["runtime"] = args?.runtime; resourceInputs["secretEnvironmentVariables"] = args?.secretEnvironmentVariables; resourceInputs["secretVolumes"] = args?.secretVolumes; resourceInputs["serviceAccountEmail"] = args?.serviceAccountEmail; resourceInputs["sourceArchiveBucket"] = args?.sourceArchiveBucket; resourceInputs["sourceArchiveObject"] = args?.sourceArchiveObject; resourceInputs["sourceRepository"] = args?.sourceRepository; resourceInputs["timeout"] = args?.timeout; resourceInputs["triggerHttp"] = args?.triggerHttp; resourceInputs["vpcConnector"] = args?.vpcConnector; resourceInputs["vpcConnectorEgressSettings"] = args?.vpcConnectorEgressSettings; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["status"] = undefined /*out*/; resourceInputs["versionId"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Function.__pulumiType, name, resourceInputs, opts); } } exports.Function = Function; //# sourceMappingURL=function.js.map