UNPKG

@pulumi/gcp

Version:

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

233 lines • 12 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.Function = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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}} * ``` * * ```sh * $ 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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["availableMemoryMb"] = state ? state.availableMemoryMb : undefined; resourceInputs["buildEnvironmentVariables"] = state ? state.buildEnvironmentVariables : undefined; resourceInputs["buildServiceAccount"] = state ? state.buildServiceAccount : undefined; resourceInputs["buildWorkerPool"] = state ? state.buildWorkerPool : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["dockerRegistry"] = state ? state.dockerRegistry : undefined; resourceInputs["dockerRepository"] = state ? state.dockerRepository : undefined; resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined; resourceInputs["entryPoint"] = state ? state.entryPoint : undefined; resourceInputs["environmentVariables"] = state ? state.environmentVariables : undefined; resourceInputs["eventTrigger"] = state ? state.eventTrigger : undefined; resourceInputs["httpsTriggerSecurityLevel"] = state ? state.httpsTriggerSecurityLevel : undefined; resourceInputs["httpsTriggerUrl"] = state ? state.httpsTriggerUrl : undefined; resourceInputs["ingressSettings"] = state ? state.ingressSettings : undefined; resourceInputs["kmsKeyName"] = state ? state.kmsKeyName : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["maxInstances"] = state ? state.maxInstances : undefined; resourceInputs["minInstances"] = state ? state.minInstances : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["runtime"] = state ? state.runtime : undefined; resourceInputs["secretEnvironmentVariables"] = state ? state.secretEnvironmentVariables : undefined; resourceInputs["secretVolumes"] = state ? state.secretVolumes : undefined; resourceInputs["serviceAccountEmail"] = state ? state.serviceAccountEmail : undefined; resourceInputs["sourceArchiveBucket"] = state ? state.sourceArchiveBucket : undefined; resourceInputs["sourceArchiveObject"] = state ? state.sourceArchiveObject : undefined; resourceInputs["sourceRepository"] = state ? state.sourceRepository : undefined; resourceInputs["status"] = state ? state.status : undefined; resourceInputs["timeout"] = state ? state.timeout : undefined; resourceInputs["triggerHttp"] = state ? state.triggerHttp : undefined; resourceInputs["versionId"] = state ? state.versionId : undefined; resourceInputs["vpcConnector"] = state ? state.vpcConnector : undefined; resourceInputs["vpcConnectorEgressSettings"] = state ? state.vpcConnectorEgressSettings : undefined; } else { const args = argsOrState; if ((!args || args.runtime === undefined) && !opts.urn) { throw new Error("Missing required property 'runtime'"); } resourceInputs["availableMemoryMb"] = args ? args.availableMemoryMb : undefined; resourceInputs["buildEnvironmentVariables"] = args ? args.buildEnvironmentVariables : undefined; resourceInputs["buildServiceAccount"] = args ? args.buildServiceAccount : undefined; resourceInputs["buildWorkerPool"] = args ? args.buildWorkerPool : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["dockerRegistry"] = args ? args.dockerRegistry : undefined; resourceInputs["dockerRepository"] = args ? args.dockerRepository : undefined; resourceInputs["entryPoint"] = args ? args.entryPoint : undefined; resourceInputs["environmentVariables"] = args ? args.environmentVariables : undefined; resourceInputs["eventTrigger"] = args ? args.eventTrigger : undefined; resourceInputs["httpsTriggerSecurityLevel"] = args ? args.httpsTriggerSecurityLevel : undefined; resourceInputs["httpsTriggerUrl"] = args ? args.httpsTriggerUrl : undefined; resourceInputs["ingressSettings"] = args ? args.ingressSettings : undefined; resourceInputs["kmsKeyName"] = args ? args.kmsKeyName : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["maxInstances"] = args ? args.maxInstances : undefined; resourceInputs["minInstances"] = args ? args.minInstances : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["runtime"] = args ? args.runtime : undefined; resourceInputs["secretEnvironmentVariables"] = args ? args.secretEnvironmentVariables : undefined; resourceInputs["secretVolumes"] = args ? args.secretVolumes : undefined; resourceInputs["serviceAccountEmail"] = args ? args.serviceAccountEmail : undefined; resourceInputs["sourceArchiveBucket"] = args ? args.sourceArchiveBucket : undefined; resourceInputs["sourceArchiveObject"] = args ? args.sourceArchiveObject : undefined; resourceInputs["sourceRepository"] = args ? args.sourceRepository : undefined; resourceInputs["timeout"] = args ? args.timeout : undefined; resourceInputs["triggerHttp"] = args ? args.triggerHttp : undefined; resourceInputs["vpcConnector"] = args ? args.vpcConnector : undefined; resourceInputs["vpcConnectorEgressSettings"] = args ? args.vpcConnectorEgressSettings : undefined; 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; /** @internal */ Function.__pulumiType = 'gcp:cloudfunctions/function:Function'; //# sourceMappingURL=function.js.map