"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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Service = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A Cloud Run service has a unique endpoint and autoscales containers.
 *
 * To get more information about Service, see:
 *
 * * [API documentation](https://cloud.google.com/run/docs/reference/rest/v1/namespaces.services)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/run/docs/)
 *
 * > **Warning:** We recommend using the `gcp.cloudrunv2.Service` resource which offers a better
 * developer experience and broader support of Cloud Run features.
 *
 * ## Example Usage
 *
 * ### Cloud Run Service Pubsub
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloud_run_service_name",
 *     location: "us-central1",
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "gcr.io/cloudrun/hello",
 *             }],
 *         },
 *     },
 *     traffics: [{
 *         percent: 100,
 *         latestRevision: true,
 *     }],
 * });
 * const sa = new gcp.serviceaccount.Account("sa", {
 *     accountId: "cloud-run-pubsub-invoker",
 *     displayName: "Cloud Run Pub/Sub Invoker",
 * });
 * const binding = new gcp.cloudrun.IamBinding("binding", {
 *     location: _default.location,
 *     service: _default.name,
 *     role: "roles/run.invoker",
 *     members: [pulumi.interpolate`serviceAccount:${sa.email}`],
 * });
 * const project = new gcp.projects.IAMBinding("project", {
 *     role: "roles/iam.serviceAccountTokenCreator",
 *     members: [pulumi.interpolate`serviceAccount:${sa.email}`],
 * });
 * const topic = new gcp.pubsub.Topic("topic", {name: "pubsub_topic"});
 * const subscription = new gcp.pubsub.Subscription("subscription", {
 *     name: "pubsub_subscription",
 *     topic: topic.name,
 *     pushConfig: {
 *         pushEndpoint: _default.statuses.apply(statuses => statuses[0].url),
 *         oidcToken: {
 *             serviceAccountEmail: sa.email,
 *         },
 *         attributes: {
 *             "x-goog-version": "v1",
 *         },
 *     },
 * });
 * ```
 *
 * ### Cloud Run Service Basic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "us-docker.pkg.dev/cloudrun/container/hello",
 *             }],
 *         },
 *     },
 *     traffics: [{
 *         percent: 100,
 *         latestRevision: true,
 *     }],
 * });
 * ```
 * ### Cloud Run Service Gpu
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     metadata: {
 *         annotations: {
 *             "run.googleapis.com/launch-stage": "BETA",
 *         },
 *     },
 *     template: {
 *         metadata: {
 *             annotations: {
 *                 "autoscaling.knative.dev/maxScale": "1",
 *                 "run.googleapis.com/cpu-throttling": "false",
 *             },
 *         },
 *         spec: {
 *             containers: [{
 *                 image: "gcr.io/cloudrun/hello",
 *                 resources: {
 *                     limits: {
 *                         cpu: "4",
 *                         memory: "16Gi",
 *                         "nvidia.com/gpu": "1",
 *                     },
 *                 },
 *             }],
 *             nodeSelector: {
 *                 "run.googleapis.com/accelerator": "nvidia-l4",
 *             },
 *         },
 *     },
 * });
 * ```
 * ### Cloud Run Service Sql
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const instance = new gcp.sql.DatabaseInstance("instance", {
 *     name: "cloudrun-sql",
 *     region: "us-east1",
 *     databaseVersion: "MYSQL_5_7",
 *     settings: {
 *         tier: "db-f1-micro",
 *     },
 *     deletionProtection: true,
 * });
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "us-docker.pkg.dev/cloudrun/container/hello",
 *             }],
 *         },
 *         metadata: {
 *             annotations: {
 *                 "autoscaling.knative.dev/maxScale": "1000",
 *                 "run.googleapis.com/cloudsql-instances": instance.connectionName,
 *                 "run.googleapis.com/client-name": "demo",
 *             },
 *         },
 *     },
 *     autogenerateRevisionName: true,
 * });
 * ```
 * ### Cloud Run Service Noauth
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "us-docker.pkg.dev/cloudrun/container/hello",
 *             }],
 *         },
 *     },
 * });
 * const noauth = gcp.organizations.getIAMPolicy({
 *     bindings: [{
 *         role: "roles/run.invoker",
 *         members: ["allUsers"],
 *     }],
 * });
 * const noauthIamPolicy = new gcp.cloudrun.IamPolicy("noauth", {
 *     location: _default.location,
 *     project: _default.project,
 *     service: _default.name,
 *     policyData: noauth.then(noauth => noauth.policyData),
 * });
 * ```
 * ### Cloud Run Service Probes
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "us-docker.pkg.dev/cloudrun/container/hello",
 *                 startupProbe: {
 *                     initialDelaySeconds: 0,
 *                     timeoutSeconds: 1,
 *                     periodSeconds: 3,
 *                     failureThreshold: 1,
 *                     tcpSocket: {
 *                         port: 8080,
 *                     },
 *                 },
 *                 livenessProbe: {
 *                     httpGet: {
 *                         path: "/",
 *                     },
 *                 },
 *             }],
 *         },
 *     },
 *     traffics: [{
 *         percent: 100,
 *         latestRevision: true,
 *     }],
 * });
 * ```
 * ### Cloud Run Service Multicontainer
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     template: {
 *         metadata: {
 *             annotations: {
 *                 "run.googleapis.com/container-dependencies": JSON.stringify({
 *                     "hello-1": ["hello-2"],
 *                 }),
 *             },
 *         },
 *         spec: {
 *             containers: [
 *                 {
 *                     name: "hello-1",
 *                     ports: [{
 *                         containerPort: 8080,
 *                     }],
 *                     image: "us-docker.pkg.dev/cloudrun/container/hello",
 *                     volumeMounts: [{
 *                         name: "shared-volume",
 *                         mountPath: "/mnt/shared",
 *                     }],
 *                 },
 *                 {
 *                     name: "hello-2",
 *                     image: "us-docker.pkg.dev/cloudrun/container/hello",
 *                     envs: [{
 *                         name: "PORT",
 *                         value: "8081",
 *                     }],
 *                     startupProbe: {
 *                         httpGet: {
 *                             port: 8081,
 *                         },
 *                     },
 *                     volumeMounts: [{
 *                         name: "shared-volume",
 *                         mountPath: "/mnt/shared",
 *                     }],
 *                 },
 *             ],
 *             volumes: [{
 *                 name: "shared-volume",
 *                 emptyDir: {
 *                     medium: "Memory",
 *                     sizeLimit: "128Mi",
 *                 },
 *             }],
 *         },
 *     },
 * });
 * ```
 * ### Cloud Run Service Iap
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const _default = new gcp.cloudrun.Service("default", {
 *     name: "cloudrun-srv",
 *     location: "us-central1",
 *     metadata: {
 *         annotations: {
 *             "run.googleapis.com/launch-stage": "BETA",
 *             "run.googleapis.com/iap-enabled": "true",
 *         },
 *     },
 *     template: {
 *         spec: {
 *             containers: [{
 *                 image: "gcr.io/cloudrun/hello",
 *             }],
 *         },
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * Service can be imported using any of these accepted formats:
 *
 * * `locations/{{location}}/namespaces/{{project}}/services/{{name}}`
 *
 * * `{{location}}/{{project}}/{{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:cloudrun/service:Service default locations/{{location}}/namespaces/{{project}}/services/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:cloudrun/service:Service default {{location}}/{{project}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:cloudrun/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 });
    }
    /**
     * 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["autogenerateRevisionName"] = state?.autogenerateRevisionName;
            resourceInputs["location"] = state?.location;
            resourceInputs["metadata"] = state?.metadata;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["statuses"] = state?.statuses;
            resourceInputs["template"] = state?.template;
            resourceInputs["traffics"] = state?.traffics;
        }
        else {
            const args = argsOrState;
            if (args?.location === undefined && !opts.urn) {
                throw new Error("Missing required property 'location'");
            }
            resourceInputs["autogenerateRevisionName"] = args?.autogenerateRevisionName;
            resourceInputs["location"] = args?.location;
            resourceInputs["metadata"] = args?.metadata;
            resourceInputs["name"] = args?.name;
            resourceInputs["project"] = args?.project;
            resourceInputs["template"] = args?.template;
            resourceInputs["traffics"] = args?.traffics;
            resourceInputs["statuses"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Service.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Service = Service;
/** @internal */
Service.__pulumiType = 'gcp:cloudrun/service:Service';
//# sourceMappingURL=service.js.map