@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
266 lines • 9.35 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** 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, Object.assign(Object.assign({}, 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 ? state.appEngineHttpTarget : undefined;
resourceInputs["attemptDeadline"] = state ? state.attemptDeadline : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["httpTarget"] = state ? state.httpTarget : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["paused"] = state ? state.paused : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["pubsubTarget"] = state ? state.pubsubTarget : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["retryConfig"] = state ? state.retryConfig : undefined;
resourceInputs["schedule"] = state ? state.schedule : undefined;
resourceInputs["state"] = state ? state.state : undefined;
resourceInputs["timeZone"] = state ? state.timeZone : undefined;
}
else {
const args = argsOrState;
resourceInputs["appEngineHttpTarget"] = args ? args.appEngineHttpTarget : undefined;
resourceInputs["attemptDeadline"] = args ? args.attemptDeadline : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["httpTarget"] = args ? args.httpTarget : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["paused"] = args ? args.paused : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["pubsubTarget"] = args ? args.pubsubTarget : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["retryConfig"] = args ? args.retryConfig : undefined;
resourceInputs["schedule"] = args ? args.schedule : undefined;
resourceInputs["timeZone"] = args ? args.timeZone : undefined;
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