UNPKG

@pulumi/gcp

Version:

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

636 lines • 23.1 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.WorkerPool = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * WorkerPool acts as a top-level container that manages a set of configurations and revision templates which implement a pull-based workload. WorkerPool exists to provide a singular abstraction which can be access controlled, reasoned about, and which encapsulates software lifecycle decisions such as rollout policy and team resource ownership. * * To get more information about WorkerPool, see: * * * [API documentation](https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.workerPools) * * How-to Guides * * [Official Documentation](https://cloud.google.com/run/docs/) * * ## Example Usage * * ### Cloudrunv2 Worker Pool Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * }], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Basic Depends On * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [ * { * name: "foo-1", * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * dependsOns: ["foo-2"], * }, * { * name: "foo-2", * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * startupProbe: { * httpGet: { * path: "/healthz", * port: 8080, * }, * periodSeconds: 5, * timeoutSeconds: 2, * failureThreshold: 3, * }, * }, * ], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Limits * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * resources: { * limits: { * cpu: "2", * memory: "1024Mi", * }, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Sql * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const secret = new gcp.secretmanager.Secret("secret", { * secretId: "secret-1", * replication: { * auto: {}, * }, * }); * const secret_version_data = new gcp.secretmanager.SecretVersion("secret-version-data", { * secret: secret.name, * secretData: "secret-data", * }); * const instance = new gcp.sql.DatabaseInstance("instance", { * name: "cloudrun-sql", * region: "us-central1", * databaseVersion: "MYSQL_5_7", * settings: { * tier: "db-f1-micro", * }, * deletionProtection: true, * }); * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * volumes: [{ * name: "cloudsql", * cloudSqlInstance: { * instances: [instance.connectionName], * }, * }], * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * envs: [ * { * name: "FOO", * value: "bar", * }, * { * name: "SECRET_ENV_VAR", * valueSource: { * secretKeyRef: { * secret: secret.secretId, * version: "1", * }, * }, * }, * ], * volumeMounts: [{ * name: "cloudsql", * mountPath: "/cloudsql", * }], * }], * }, * instanceSplits: [{ * type: "INSTANCE_SPLIT_ALLOCATION_TYPE_LATEST", * percent: 100, * }], * }, { * dependsOn: [secret_version_data], * }); * const project = gcp.organizations.getProject({}); * const secret_access = new gcp.secretmanager.SecretIamMember("secret-access", { * secretId: secret.id, * role: "roles/secretmanager.secretAccessor", * member: project.then(project => `serviceAccount:${project.number}-compute@developer.gserviceaccount.com`), * }, { * dependsOn: [secret], * }); * ``` * ### Cloudrunv2 Worker Pool Directvpc * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * }], * vpcAccess: { * networkInterfaces: [{ * network: "default", * subnetwork: "default", * tags: [ * "tag1", * "tag2", * "tag3", * ], * }], * }, * }, * }); * ``` * ### Cloudrunv2 Worker Pool Gpu * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * resources: { * limits: { * cpu: "4", * memory: "16Gi", * "nvidia.com/gpu": "1", * }, * }, * }], * nodeSelector: { * accelerator: "nvidia-l4", * }, * gpuZonalRedundancyDisabled: true, * }, * }); * ``` * ### Cloudrunv2 Worker Pool Secret * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const secret = new gcp.secretmanager.Secret("secret", { * secretId: "secret-1", * replication: { * auto: {}, * }, * }); * const secret_version_data = new gcp.secretmanager.SecretVersion("secret-version-data", { * secret: secret.name, * secretData: "secret-data", * }); * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * volumes: [{ * name: "a-volume", * secret: { * secret: secret.secretId, * defaultMode: 292, * items: [{ * version: "1", * path: "my-secret", * mode: 444, * }], * }, * }], * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * volumeMounts: [{ * name: "a-volume", * mountPath: "/secrets", * }], * }], * }, * }, { * dependsOn: [secret_version_data], * }); * const project = gcp.organizations.getProject({}); * const secret_access = new gcp.secretmanager.SecretIamMember("secret-access", { * secretId: secret.id, * role: "roles/secretmanager.secretAccessor", * member: project.then(project => `serviceAccount:${project.number}-compute@developer.gserviceaccount.com`), * }, { * dependsOn: [secret], * }); * ``` * ### Cloudrunv2 Worker Pool Multicontainer * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [ * { * name: "hello-1", * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * volumeMounts: [{ * name: "empty-dir-volume", * mountPath: "/mnt", * }], * }, * { * name: "hello-2", * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * }, * ], * volumes: [{ * name: "empty-dir-volume", * emptyDir: { * medium: "MEMORY", * sizeLimit: "256Mi", * }, * }], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Mount Gcs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultBucket = new gcp.storage.Bucket("default", { * name: "cloudrun-worker-pool", * location: "US", * uniformBucketLevelAccess: true, * }); * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * volumeMounts: [{ * name: "bucket", * mountPath: "/var/www", * }], * }], * volumes: [{ * name: "bucket", * gcs: { * bucket: defaultBucket.name, * readOnly: false, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Emptydir Disk * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * launchStage: "BETA", * deletionProtection: true, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool", * volumeMounts: [{ * name: "empty-dir-volume", * mountPath: "/mnt", * }], * }], * volumes: [{ * name: "empty-dir-volume", * emptyDir: { * medium: "DISK", * sizeLimit: "10Gi", * }, * }], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Mount Nfs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultInstance = new gcp.filestore.Instance("default", { * name: "cloudrun-worker-pool", * location: "us-central1-b", * tier: "BASIC_HDD", * fileShares: { * capacityGb: 1024, * name: "share1", * }, * networks: [{ * network: "default", * modes: ["MODE_IPV4"], * }], * }); * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/worker-pool:latest", * volumeMounts: [{ * name: "nfs", * mountPath: "/mnt/nfs/filestore", * }], * }], * vpcAccess: { * networkInterfaces: [{ * network: "default", * subnetwork: "default", * }], * }, * volumes: [{ * name: "nfs", * nfs: { * server: defaultInstance.networks.apply(networks => networks[0].ipAddresses?.[0]), * path: "/share1", * readOnly: false, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Worker Pool Startup Liveness Probe * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const customTest = new gcp.compute.Network("custom_test", { * name: "wp-net", * autoCreateSubnetworks: false, * }); * const customTestSubnetwork = new gcp.compute.Subnetwork("custom_test", { * name: "wp-subnet", * ipCidrRange: "10.2.0.0/28", * region: "us-central1", * network: customTest.id, * }); * const _default = new gcp.cloudrunv2.WorkerPool("default", { * name: "cloudrun-worker-pool", * location: "us-central1", * deletionProtection: false, * template: { * annotations: {}, * labels: {}, * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * commands: [], * args: [], * startupProbe: { * initialDelaySeconds: 0, * timeoutSeconds: 1, * periodSeconds: 3, * failureThreshold: 3, * tcpSocket: { * port: 8080, * }, * }, * livenessProbe: { * initialDelaySeconds: 0, * timeoutSeconds: 1, * periodSeconds: 10, * failureThreshold: 3, * httpGet: { * path: "/", * port: 8080, * }, * }, * }], * vpcAccess: { * networkInterfaces: [{ * network: customTest.id, * subnetwork: customTestSubnetwork.id, * tags: [], * }], * }, * }, * }); * ``` * * ## Import * * WorkerPool can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/workerPools/{{name}}` * * `{{project}}/{{location}}/{{name}}` * * `{{location}}/{{name}}` * * When using the `pulumi import` command, WorkerPool can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:cloudrunv2/workerPool:WorkerPool default projects/{{project}}/locations/{{location}}/workerPools/{{name}} * $ pulumi import gcp:cloudrunv2/workerPool:WorkerPool default {{project}}/{{location}}/{{name}} * $ pulumi import gcp:cloudrunv2/workerPool:WorkerPool default {{location}}/{{name}} * ``` */ class WorkerPool extends pulumi.CustomResource { /** * Get an existing WorkerPool 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 WorkerPool(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:cloudrunv2/workerPool:WorkerPool'; /** * Returns true if the given object is an instance of WorkerPool. 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'] === WorkerPool.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["annotations"] = state?.annotations; resourceInputs["binaryAuthorization"] = state?.binaryAuthorization; resourceInputs["client"] = state?.client; resourceInputs["clientVersion"] = state?.clientVersion; resourceInputs["conditions"] = state?.conditions; resourceInputs["createTime"] = state?.createTime; resourceInputs["creator"] = state?.creator; resourceInputs["customAudiences"] = state?.customAudiences; resourceInputs["deleteTime"] = state?.deleteTime; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["deletionProtection"] = state?.deletionProtection; resourceInputs["description"] = state?.description; resourceInputs["effectiveAnnotations"] = state?.effectiveAnnotations; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["etag"] = state?.etag; resourceInputs["expireTime"] = state?.expireTime; resourceInputs["generation"] = state?.generation; resourceInputs["instanceSplitStatuses"] = state?.instanceSplitStatuses; resourceInputs["instanceSplits"] = state?.instanceSplits; resourceInputs["labels"] = state?.labels; resourceInputs["lastModifier"] = state?.lastModifier; resourceInputs["latestCreatedRevision"] = state?.latestCreatedRevision; resourceInputs["latestReadyRevision"] = state?.latestReadyRevision; resourceInputs["launchStage"] = state?.launchStage; resourceInputs["location"] = state?.location; resourceInputs["name"] = state?.name; resourceInputs["observedGeneration"] = state?.observedGeneration; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["reconciling"] = state?.reconciling; resourceInputs["scaling"] = state?.scaling; resourceInputs["template"] = state?.template; resourceInputs["terminalConditions"] = state?.terminalConditions; resourceInputs["uid"] = state?.uid; resourceInputs["updateTime"] = state?.updateTime; } else { const args = argsOrState; if (args?.location === undefined && !opts.urn) { throw new Error("Missing required property 'location'"); } if (args?.template === undefined && !opts.urn) { throw new Error("Missing required property 'template'"); } resourceInputs["annotations"] = args?.annotations; resourceInputs["binaryAuthorization"] = args?.binaryAuthorization; resourceInputs["client"] = args?.client; resourceInputs["clientVersion"] = args?.clientVersion; resourceInputs["customAudiences"] = args?.customAudiences; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["description"] = args?.description; resourceInputs["instanceSplits"] = args?.instanceSplits; resourceInputs["labels"] = args?.labels; resourceInputs["launchStage"] = args?.launchStage; resourceInputs["location"] = args?.location; resourceInputs["name"] = args?.name; resourceInputs["project"] = args?.project; resourceInputs["scaling"] = args?.scaling; resourceInputs["template"] = args?.template; resourceInputs["conditions"] = undefined /*out*/; resourceInputs["createTime"] = undefined /*out*/; resourceInputs["creator"] = undefined /*out*/; resourceInputs["deleteTime"] = undefined /*out*/; resourceInputs["effectiveAnnotations"] = undefined /*out*/; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["etag"] = undefined /*out*/; resourceInputs["expireTime"] = undefined /*out*/; resourceInputs["generation"] = undefined /*out*/; resourceInputs["instanceSplitStatuses"] = undefined /*out*/; resourceInputs["lastModifier"] = undefined /*out*/; resourceInputs["latestCreatedRevision"] = undefined /*out*/; resourceInputs["latestReadyRevision"] = undefined /*out*/; resourceInputs["observedGeneration"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["reconciling"] = undefined /*out*/; resourceInputs["terminalConditions"] = undefined /*out*/; resourceInputs["uid"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(WorkerPool.__pulumiType, name, resourceInputs, opts); } } exports.WorkerPool = WorkerPool; //# sourceMappingURL=workerPool.js.map