UNPKG

@pulumi/gcp

Version:

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

208 lines • 9.94 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Job = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Creates a job on Dataflow, which is an implementation of Apache Beam running on Google Compute Engine. For more information see * the official documentation for * [Beam](https://beam.apache.org) and [Dataflow](https://cloud.google.com/dataflow/). * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const bigDataJob = new gcp.dataflow.Job("big_data_job", { * name: "dataflow-job", * templateGcsPath: "gs://my-bucket/templates/template_file", * tempGcsLocation: "gs://my-bucket/tmp_dir", * parameters: { * foo: "bar", * baz: "qux", * }, * }); * ``` * * ### Streaming Job * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const topic = new gcp.pubsub.Topic("topic", {name: "dataflow-job1"}); * const bucket1 = new gcp.storage.Bucket("bucket1", { * name: "tf-test-bucket1", * location: "US", * forceDestroy: true, * }); * const bucket2 = new gcp.storage.Bucket("bucket2", { * name: "tf-test-bucket2", * location: "US", * forceDestroy: true, * }); * const pubsubStream = new gcp.dataflow.Job("pubsub_stream", { * name: "tf-test-dataflow-job1", * templateGcsPath: "gs://my-bucket/templates/template_file", * tempGcsLocation: "gs://my-bucket/tmp_dir", * enableStreamingEngine: true, * parameters: { * inputFilePattern: pulumi.interpolate`${bucket1.url}/*.json`, * outputTopic: topic.id, * }, * transformNameMapping: { * name: "test_job", * env: "test", * }, * onDelete: "cancel", * }); * ``` * * ## Note on "destroy" / "apply" * * There are many types of Dataflow jobs. Some Dataflow jobs run constantly, getting new data from (e.g.) a GCS bucket, and outputting data continuously. Some jobs process a set amount of data then terminate. All jobs can fail while running due to programming errors or other issues. In this way, Dataflow jobs are different from most other Google resources. * * The Dataflow resource is considered 'existing' while it is in a nonterminal state. If it reaches a terminal state (e.g. 'FAILED', 'COMPLETE', 'CANCELLED'), it will be recreated on the next 'apply'. This is as expected for jobs which run continuously, but may surprise users who use this resource for other kinds of Dataflow jobs. * * A Dataflow job which is 'destroyed' may be "cancelled" or "drained". If "cancelled", the job terminates - any data written remains where it is, but no new data will be processed. If "drained", no new data will enter the pipeline, but any data currently in the pipeline will finish being processed. The default is "drain". When `onDelete` is set to `"drain"` in the configuration, you may experience a long wait for your `pulumi destroy` to complete. * * You can potentially short-circuit the wait by setting `skipWaitOnJobTermination` to `true`, but beware that unless you take active steps to ensure that the job `name` parameter changes between instances, the name will conflict and the launch of the new job will fail. One way to do this is with a randomId resource, for example: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as random from "@pulumi/random"; * * const config = new pulumi.Config(); * const bigDataJobSubscriptionId = config.get("bigDataJobSubscriptionId") || "projects/myproject/subscriptions/messages"; * const bigDataJobNameSuffix = new random.RandomId("big_data_job_name_suffix", { * byteLength: 4, * keepers: { * region: region, * subscription_id: bigDataJobSubscriptionId, * }, * }); * const bigDataJob = new gcp.dataflow.FlexTemplateJob("big_data_job", { * name: pulumi.interpolate`dataflow-flextemplates-job-${bigDataJobNameSuffix.dec}`, * region: region, * containerSpecGcsPath: "gs://my-bucket/templates/template.json", * skipWaitOnJobTermination: true, * parameters: { * inputSubscription: bigDataJobSubscriptionId, * }, * }); * ``` * * ## Import * * Dataflow jobs can be imported using the job `id` e.g. * * * `{{id}}` * * When using the `pulumi import` command, dataflow jobs can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:dataflow/job:Job default {{id}} * ``` */ class Job extends pulumi.CustomResource { /** * Get an existing Job 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 Job(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Job. 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'] === Job.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["additionalExperiments"] = state?.additionalExperiments; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["enableStreamingEngine"] = state?.enableStreamingEngine; resourceInputs["ipConfiguration"] = state?.ipConfiguration; resourceInputs["jobId"] = state?.jobId; resourceInputs["kmsKeyName"] = state?.kmsKeyName; resourceInputs["labels"] = state?.labels; resourceInputs["machineType"] = state?.machineType; resourceInputs["maxWorkers"] = state?.maxWorkers; resourceInputs["name"] = state?.name; resourceInputs["network"] = state?.network; resourceInputs["onDelete"] = state?.onDelete; resourceInputs["parameters"] = state?.parameters; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["region"] = state?.region; resourceInputs["serviceAccountEmail"] = state?.serviceAccountEmail; resourceInputs["skipWaitOnJobTermination"] = state?.skipWaitOnJobTermination; resourceInputs["state"] = state?.state; resourceInputs["subnetwork"] = state?.subnetwork; resourceInputs["tempGcsLocation"] = state?.tempGcsLocation; resourceInputs["templateGcsPath"] = state?.templateGcsPath; resourceInputs["transformNameMapping"] = state?.transformNameMapping; resourceInputs["type"] = state?.type; resourceInputs["zone"] = state?.zone; } else { const args = argsOrState; if (args?.tempGcsLocation === undefined && !opts.urn) { throw new Error("Missing required property 'tempGcsLocation'"); } if (args?.templateGcsPath === undefined && !opts.urn) { throw new Error("Missing required property 'templateGcsPath'"); } resourceInputs["additionalExperiments"] = args?.additionalExperiments; resourceInputs["enableStreamingEngine"] = args?.enableStreamingEngine; resourceInputs["ipConfiguration"] = args?.ipConfiguration; resourceInputs["kmsKeyName"] = args?.kmsKeyName; resourceInputs["labels"] = args?.labels; resourceInputs["machineType"] = args?.machineType; resourceInputs["maxWorkers"] = args?.maxWorkers; resourceInputs["name"] = args?.name; resourceInputs["network"] = args?.network; resourceInputs["onDelete"] = args?.onDelete; resourceInputs["parameters"] = args?.parameters; resourceInputs["project"] = args?.project; resourceInputs["region"] = args?.region; resourceInputs["serviceAccountEmail"] = args?.serviceAccountEmail; resourceInputs["skipWaitOnJobTermination"] = args?.skipWaitOnJobTermination; resourceInputs["subnetwork"] = args?.subnetwork; resourceInputs["tempGcsLocation"] = args?.tempGcsLocation; resourceInputs["templateGcsPath"] = args?.templateGcsPath; resourceInputs["transformNameMapping"] = args?.transformNameMapping; resourceInputs["zone"] = args?.zone; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["jobId"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["type"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Job.__pulumiType, name, resourceInputs, opts); } } exports.Job = Job; /** @internal */ Job.__pulumiType = 'gcp:dataflow/job:Job'; //# sourceMappingURL=job.js.map