UNPKG

@pulumi/gcp

Version:

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

798 lines • 28.3 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.Service = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Service acts as a top-level container that manages a set of configurations and revision templates which implement a network service. Service 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 Service, see: * * * [API documentation](https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services) * * How-to Guides * * [Official Documentation](https://cloud.google.com/run/docs/) * * ## Example Usage * * ### Cloudrunv2 Service Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * scaling: { * maxInstanceCount: 100, * }, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * }], * }, * }); * ``` * ### Cloudrunv2 Service Limits * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * template: { * healthCheckDisabled: true, * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * resources: { * limits: { * cpu: "2", * memory: "1024Mi", * }, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Service 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.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * scaling: { * maxInstanceCount: 2, * }, * template: { * volumes: [{ * name: "cloudsql", * cloudSqlInstance: { * instances: [instance.connectionName], * }, * }], * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * envs: [ * { * name: "FOO", * value: "bar", * }, * { * name: "SECRET_ENV_VAR", * valueSource: { * secretKeyRef: { * secret: secret.secretId, * version: "1", * }, * }, * }, * ], * volumeMounts: [{ * name: "cloudsql", * mountPath: "/cloudsql", * }], * }], * }, * traffics: [{ * type: "TRAFFIC_TARGET_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 Service Vpcaccess * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const customTestNetwork = new gcp.compute.Network("custom_test", { * name: "run-network", * autoCreateSubnetworks: false, * }); * const customTest = new gcp.compute.Subnetwork("custom_test", { * name: "run-subnetwork", * ipCidrRange: "10.2.0.0/28", * region: "us-central1", * network: customTestNetwork.id, * }); * const connector = new gcp.vpcaccess.Connector("connector", { * name: "run-vpc", * subnet: { * name: customTest.name, * }, * machineType: "e2-standard-4", * minInstances: 2, * maxInstances: 3, * region: "us-central1", * }); * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * }], * vpcAccess: { * connector: connector.id, * egress: "ALL_TRAFFIC", * }, * }, * }); * ``` * ### Cloudrunv2 Service Directvpc * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * launchStage: "GA", * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * }], * vpcAccess: { * networkInterfaces: [{ * network: "default", * subnetwork: "default", * tags: [ * "tag1", * "tag2", * "tag3", * ], * }], * }, * }, * }); * ``` * ### Cloudrunv2 Service Gpu * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * scaling: { * maxInstanceCount: 1, * }, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * resources: { * limits: { * cpu: "4", * memory: "16Gi", * "nvidia.com/gpu": "1", * }, * startupCpuBoost: true, * }, * }], * nodeSelector: { * accelerator: "nvidia-l4", * }, * gpuZonalRedundancyDisabled: true, * }, * }); * ``` * ### Cloudrunv2 Service Probes * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * startupProbe: { * initialDelaySeconds: 0, * timeoutSeconds: 1, * periodSeconds: 3, * failureThreshold: 1, * tcpSocket: { * port: 8080, * }, * }, * livenessProbe: { * httpGet: { * path: "/", * }, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Service Readiness Probes * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * launchStage: "BETA", * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * readinessProbe: { * timeoutSeconds: 20, * periodSeconds: 30, * successThreshold: 3, * failureThreshold: 2, * grpc: { * port: 8080, * }, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Service 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.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * template: { * volumes: [{ * name: "a-volume", * secret: { * secret: secret.secretId, * defaultMode: 292, * items: [{ * version: "1", * path: "my-secret", * }], * }, * }], * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * 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 Service Multicontainer * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * template: { * containers: [ * { * name: "hello-1", * ports: { * containerPort: 8080, * }, * image: "us-docker.pkg.dev/cloudrun/container/hello", * dependsOns: ["hello-2"], * volumeMounts: [{ * name: "empty-dir-volume", * mountPath: "/mnt", * }], * }, * { * name: "hello-2", * image: "us-docker.pkg.dev/cloudrun/container/hello", * envs: [{ * name: "PORT", * value: "8081", * }], * startupProbe: { * httpGet: { * port: 8081, * }, * }, * }, * ], * volumes: [{ * name: "empty-dir-volume", * emptyDir: { * medium: "MEMORY", * sizeLimit: "256Mi", * }, * }], * }, * }); * ``` * ### Cloudrunv2 Service Mount Gcs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultBucket = new gcp.storage.Bucket("default", { * name: "cloudrun-service", * location: "US", * }); * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * template: { * executionEnvironment: "EXECUTION_ENVIRONMENT_GEN2", * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * volumeMounts: [{ * name: "bucket", * mountPath: "/var/www", * }], * }], * volumes: [{ * name: "bucket", * gcs: { * bucket: defaultBucket.name, * readOnly: false, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Service Mount Nfs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultInstance = new gcp.filestore.Instance("default", { * name: "cloudrun-service", * location: "us-central1-b", * tier: "BASIC_HDD", * fileShares: { * capacityGb: 1024, * name: "share1", * }, * networks: [{ * network: "default", * modes: ["MODE_IPV4"], * }], * }); * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * template: { * executionEnvironment: "EXECUTION_ENVIRONMENT_GEN2", * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello: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 Service Mesh * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as time from "@pulumiverse/time"; * * const mesh = new gcp.networkservices.Mesh("mesh", {name: "network-services-mesh"}); * const waitForMesh = new time.Sleep("wait_for_mesh", {createDuration: "1m"}, { * dependsOn: [mesh], * }); * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * deletionProtection: false, * location: "us-central1", * launchStage: "BETA", * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * }], * serviceMesh: { * mesh: mesh.id, * }, * }, * }, { * dependsOn: [waitForMesh], * }); * ``` * ### Cloudrunv2 Service Invokeriam * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * deletionProtection: false, * invokerIamDisabled: true, * description: "The serving URL of this service will not perform any IAM check when invoked", * ingress: "INGRESS_TRAFFIC_ALL", * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * }], * }, * }); * ``` * ### Cloudrunv2 Service Iap * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-iap-service", * location: "us-central1", * deletionProtection: false, * ingress: "INGRESS_TRAFFIC_ALL", * iapEnabled: true, * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * }], * }, * }); * ``` * ### Cloudrunv2 Service Zip Deploy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const sourcebucket = new gcp.storage.Bucket("sourcebucket", { * name: project.then(project => `${project.projectId}-tf-test-gcf-source_91042`), * location: "US", * uniformBucketLevelAccess: true, * }); * const sourceTar = new gcp.storage.BucketObject("source_tar", { * name: "function-source.zip", * bucket: sourcebucket.name, * source: new pulumi.asset.FileAsset("./test-fixtures/cr-zip-nodejs-hello.tar.gz"), * }); * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-zip-service", * location: "us-central1", * deletionProtection: false, * template: { * containers: [{ * image: "scratch", * baseImageUri: "us-central1-docker.pkg.dev/serverless-runtimes/google-24-full/runtimes/nodejs24", * commands: ["node"], * args: ["index.js"], * sourceCode: { * cloudStorageSource: { * bucket: sourcebucket.name, * object: sourceTar.name, * generation: sourceTar.generation.apply(x =>String(x)), * }, * }, * }], * }, * }); * ``` * ### Cloudrunv2 Service Emptydir Disk * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.cloudrunv2.Service("default", { * name: "cloudrun-service", * location: "us-central1", * launchStage: "ALPHA", * deletionProtection: true, * ingress: "INGRESS_TRAFFIC_ALL", * template: { * containers: [{ * image: "us-docker.pkg.dev/cloudrun/container/hello", * volumeMounts: [{ * name: "empty-dir-volume", * mountPath: "/mnt", * }], * }], * volumes: [{ * name: "empty-dir-volume", * emptyDir: { * medium: "DISK", * sizeLimit: "10Gi", * }, * }], * }, * }); * ``` * * ## Import * * Service can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/services/{{name}}` * * `{{project}}/{{location}}/{{name}}` * * `{{location}}/{{name}}` * * When using the `pulumi import` command, Service can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:cloudrunv2/service:Service default projects/{{project}}/locations/{{location}}/services/{{name}} * $ pulumi import gcp:cloudrunv2/service:Service default {{project}}/{{location}}/{{name}} * $ pulumi import gcp:cloudrunv2/service:Service default {{location}}/{{name}} * ``` */ class Service extends pulumi.CustomResource { /** * Get an existing Service 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 Service(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:cloudrunv2/service:Service'; /** * Returns true if the given object is an instance of Service. 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'] === Service.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["annotations"] = state?.annotations; resourceInputs["binaryAuthorization"] = state?.binaryAuthorization; resourceInputs["buildConfig"] = state?.buildConfig; 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["defaultUriDisabled"] = state?.defaultUriDisabled; 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["iapEnabled"] = state?.iapEnabled; resourceInputs["ingress"] = state?.ingress; resourceInputs["invokerIamDisabled"] = state?.invokerIamDisabled; 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["multiRegionSettings"] = state?.multiRegionSettings; 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["trafficStatuses"] = state?.trafficStatuses; resourceInputs["traffics"] = state?.traffics; resourceInputs["uid"] = state?.uid; resourceInputs["updateTime"] = state?.updateTime; resourceInputs["uri"] = state?.uri; resourceInputs["urls"] = state?.urls; } 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["buildConfig"] = args?.buildConfig; resourceInputs["client"] = args?.client; resourceInputs["clientVersion"] = args?.clientVersion; resourceInputs["customAudiences"] = args?.customAudiences; resourceInputs["defaultUriDisabled"] = args?.defaultUriDisabled; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["description"] = args?.description; resourceInputs["iapEnabled"] = args?.iapEnabled; resourceInputs["ingress"] = args?.ingress; resourceInputs["invokerIamDisabled"] = args?.invokerIamDisabled; resourceInputs["labels"] = args?.labels; resourceInputs["launchStage"] = args?.launchStage; resourceInputs["location"] = args?.location; resourceInputs["multiRegionSettings"] = args?.multiRegionSettings; resourceInputs["name"] = args?.name; resourceInputs["project"] = args?.project; resourceInputs["scaling"] = args?.scaling; resourceInputs["template"] = args?.template; resourceInputs["traffics"] = args?.traffics; 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["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["trafficStatuses"] = undefined /*out*/; resourceInputs["uid"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; resourceInputs["uri"] = undefined /*out*/; resourceInputs["urls"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Service.__pulumiType, name, resourceInputs, opts); } } exports.Service = Service; //# sourceMappingURL=service.js.map