@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
266 lines • 8.84 kB
JavaScript
// *** 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");
/**
* A scheduled job that can publish a PubSub message or an HTTP request
* every X interval of time, using a crontab format string.
*
* To get more information about Job, see:
*
* * [API documentation](https://cloud.google.com/scheduler/docs/reference/rest/)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/scheduler/)
*
* ## Example Usage
*
* ### Scheduler Job Pubsub
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as std from "@pulumi/std";
*
* const topic = new gcp.pubsub.Topic("topic", {name: "job-topic"});
* const job = new gcp.cloudscheduler.Job("job", {
* name: "test-job",
* description: "test job",
* schedule: "*/2 * * * *",
* pubsubTarget: {
* topicName: topic.id,
* data: std.base64encode({
* input: "test",
* }).then(invoke => invoke.result),
* },
* });
* ```
* ### Scheduler Job Http
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as std from "@pulumi/std";
*
* const job = new gcp.cloudscheduler.Job("job", {
* name: "test-job",
* description: "test http job",
* schedule: "*/8 * * * *",
* timeZone: "America/New_York",
* attemptDeadline: "320s",
* retryConfig: {
* retryCount: 1,
* },
* httpTarget: {
* httpMethod: "POST",
* uri: "https://example.com/",
* body: std.base64encode({
* input: "{\"foo\":\"bar\"}",
* }).then(invoke => invoke.result),
* headers: {
* "Content-Type": "application/json",
* },
* },
* });
* ```
* ### Scheduler Job Paused
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as std from "@pulumi/std";
*
* const job = new gcp.cloudscheduler.Job("job", {
* paused: true,
* name: "test-job",
* description: "test http job with updated fields",
* schedule: "*/8 * * * *",
* timeZone: "America/New_York",
* attemptDeadline: "320s",
* retryConfig: {
* retryCount: 1,
* },
* httpTarget: {
* httpMethod: "POST",
* uri: "https://example.com/ping",
* body: std.base64encode({
* input: "{\"foo\":\"bar\"}",
* }).then(invoke => invoke.result),
* headers: {
* "Content-Type": "application/json",
* },
* },
* });
* ```
* ### Scheduler Job App Engine
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const job = new gcp.cloudscheduler.Job("job", {
* name: "test-job",
* schedule: "*/4 * * * *",
* description: "test app engine job",
* timeZone: "Europe/London",
* attemptDeadline: "320s",
* retryConfig: {
* minBackoffDuration: "1s",
* maxRetryDuration: "10s",
* maxDoublings: 2,
* retryCount: 3,
* },
* appEngineHttpTarget: {
* httpMethod: "POST",
* appEngineRouting: {
* service: "web",
* version: "prod",
* instance: "my-instance-001",
* },
* relativeUri: "/ping",
* },
* });
* ```
* ### Scheduler Job Oauth
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = gcp.compute.getDefaultServiceAccount({});
* const job = new gcp.cloudscheduler.Job("job", {
* name: "test-job",
* description: "test http job",
* schedule: "*/8 * * * *",
* timeZone: "America/New_York",
* attemptDeadline: "320s",
* httpTarget: {
* httpMethod: "GET",
* uri: "https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs",
* oauthToken: {
* serviceAccountEmail: _default.then(_default => _default.email),
* },
* },
* });
* ```
* ### Scheduler Job Oidc
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = gcp.compute.getDefaultServiceAccount({});
* const job = new gcp.cloudscheduler.Job("job", {
* name: "test-job",
* description: "test http job",
* schedule: "*/8 * * * *",
* timeZone: "America/New_York",
* attemptDeadline: "320s",
* httpTarget: {
* httpMethod: "GET",
* uri: "https://example.com/ping",
* oidcToken: {
* serviceAccountEmail: _default.then(_default => _default.email),
* },
* },
* });
* ```
*
* ## Import
*
* Job can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{region}}/jobs/{{name}}`
*
* * `{{project}}/{{region}}/{{name}}`
*
* * `{{region}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, Job can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:cloudscheduler/job:Job default projects/{{project}}/locations/{{region}}/jobs/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:cloudscheduler/job:Job default {{project}}/{{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:cloudscheduler/job:Job default {{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:cloudscheduler/job:Job default {{name}}
* ```
*/
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["appEngineHttpTarget"] = state?.appEngineHttpTarget;
resourceInputs["attemptDeadline"] = state?.attemptDeadline;
resourceInputs["description"] = state?.description;
resourceInputs["httpTarget"] = state?.httpTarget;
resourceInputs["name"] = state?.name;
resourceInputs["paused"] = state?.paused;
resourceInputs["project"] = state?.project;
resourceInputs["pubsubTarget"] = state?.pubsubTarget;
resourceInputs["region"] = state?.region;
resourceInputs["retryConfig"] = state?.retryConfig;
resourceInputs["schedule"] = state?.schedule;
resourceInputs["state"] = state?.state;
resourceInputs["timeZone"] = state?.timeZone;
}
else {
const args = argsOrState;
resourceInputs["appEngineHttpTarget"] = args?.appEngineHttpTarget;
resourceInputs["attemptDeadline"] = args?.attemptDeadline;
resourceInputs["description"] = args?.description;
resourceInputs["httpTarget"] = args?.httpTarget;
resourceInputs["name"] = args?.name;
resourceInputs["paused"] = args?.paused;
resourceInputs["project"] = args?.project;
resourceInputs["pubsubTarget"] = args?.pubsubTarget;
resourceInputs["region"] = args?.region;
resourceInputs["retryConfig"] = args?.retryConfig;
resourceInputs["schedule"] = args?.schedule;
resourceInputs["timeZone"] = args?.timeZone;
resourceInputs["state"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Job.__pulumiType, name, resourceInputs, opts);
}
}
exports.Job = Job;
/** @internal */
Job.__pulumiType = 'gcp:cloudscheduler/job:Job';
//# sourceMappingURL=job.js.map
;