@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
459 lines (458 loc) • 16.3 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* 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}}
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: JobState, opts?: pulumi.CustomResourceOptions): Job;
/**
* 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: any): obj is Job;
/**
* App Engine HTTP target.
* If the job providers a App Engine HTTP target the cron will
* send a request to the service instance
* Structure is documented below.
*/
readonly appEngineHttpTarget: pulumi.Output<outputs.cloudscheduler.JobAppEngineHttpTarget | undefined>;
/**
* The deadline for job attempts. If the request handler does not respond by this deadline then the request is
* cancelled and the attempt is marked as a DEADLINE_EXCEEDED failure. The failed attempt can be viewed in
* execution logs. Cloud Scheduler will retry the job according to the RetryConfig.
* The allowed duration for this deadline is:
* * For HTTP targets, between 15 seconds and 30 minutes.
* * For App Engine HTTP targets, between 15 seconds and 24 hours.
* * **Note**: For PubSub targets, this field is ignored - setting it will introduce an unresolvable diff.
* A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s"
*/
readonly attemptDeadline: pulumi.Output<string | undefined>;
/**
* A human-readable description for the job.
* This string must not contain more than 500 characters.
*/
readonly description: pulumi.Output<string | undefined>;
/**
* HTTP target.
* If the job providers a httpTarget the cron will
* send a request to the targeted url
* Structure is documented below.
*/
readonly httpTarget: pulumi.Output<outputs.cloudscheduler.JobHttpTarget | undefined>;
/**
* The name of the job.
*
*
* - - -
*/
readonly name: pulumi.Output<string>;
/**
* Sets the job to a paused state. Jobs default to being enabled when this property is not set.
*/
readonly paused: pulumi.Output<boolean>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
readonly project: pulumi.Output<string>;
/**
* Pub/Sub target
* If the job providers a Pub/Sub target the cron will publish
* a message to the provided topic
* Structure is documented below.
*/
readonly pubsubTarget: pulumi.Output<outputs.cloudscheduler.JobPubsubTarget | undefined>;
/**
* Region where the scheduler job resides. If it is not provided, this provider will use the provider default.
*/
readonly region: pulumi.Output<string>;
/**
* By default, if a job does not complete successfully,
* meaning that an acknowledgement is not received from the handler,
* then it will be retried with exponential backoff according to the settings
* Structure is documented below.
*/
readonly retryConfig: pulumi.Output<outputs.cloudscheduler.JobRetryConfig | undefined>;
/**
* Describes the schedule on which the job will be executed.
*/
readonly schedule: pulumi.Output<string | undefined>;
/**
* State of the job.
*/
readonly state: pulumi.Output<string>;
/**
* Specifies the time zone to be used in interpreting schedule.
* The value of this field must be a time zone name from the tz database.
*/
readonly timeZone: pulumi.Output<string | undefined>;
/**
* Create a Job resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: JobArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Job resources.
*/
export interface JobState {
/**
* App Engine HTTP target.
* If the job providers a App Engine HTTP target the cron will
* send a request to the service instance
* Structure is documented below.
*/
appEngineHttpTarget?: pulumi.Input<inputs.cloudscheduler.JobAppEngineHttpTarget>;
/**
* The deadline for job attempts. If the request handler does not respond by this deadline then the request is
* cancelled and the attempt is marked as a DEADLINE_EXCEEDED failure. The failed attempt can be viewed in
* execution logs. Cloud Scheduler will retry the job according to the RetryConfig.
* The allowed duration for this deadline is:
* * For HTTP targets, between 15 seconds and 30 minutes.
* * For App Engine HTTP targets, between 15 seconds and 24 hours.
* * **Note**: For PubSub targets, this field is ignored - setting it will introduce an unresolvable diff.
* A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s"
*/
attemptDeadline?: pulumi.Input<string>;
/**
* A human-readable description for the job.
* This string must not contain more than 500 characters.
*/
description?: pulumi.Input<string>;
/**
* HTTP target.
* If the job providers a httpTarget the cron will
* send a request to the targeted url
* Structure is documented below.
*/
httpTarget?: pulumi.Input<inputs.cloudscheduler.JobHttpTarget>;
/**
* The name of the job.
*
*
* - - -
*/
name?: pulumi.Input<string>;
/**
* Sets the job to a paused state. Jobs default to being enabled when this property is not set.
*/
paused?: pulumi.Input<boolean>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string>;
/**
* Pub/Sub target
* If the job providers a Pub/Sub target the cron will publish
* a message to the provided topic
* Structure is documented below.
*/
pubsubTarget?: pulumi.Input<inputs.cloudscheduler.JobPubsubTarget>;
/**
* Region where the scheduler job resides. If it is not provided, this provider will use the provider default.
*/
region?: pulumi.Input<string>;
/**
* By default, if a job does not complete successfully,
* meaning that an acknowledgement is not received from the handler,
* then it will be retried with exponential backoff according to the settings
* Structure is documented below.
*/
retryConfig?: pulumi.Input<inputs.cloudscheduler.JobRetryConfig>;
/**
* Describes the schedule on which the job will be executed.
*/
schedule?: pulumi.Input<string>;
/**
* State of the job.
*/
state?: pulumi.Input<string>;
/**
* Specifies the time zone to be used in interpreting schedule.
* The value of this field must be a time zone name from the tz database.
*/
timeZone?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a Job resource.
*/
export interface JobArgs {
/**
* App Engine HTTP target.
* If the job providers a App Engine HTTP target the cron will
* send a request to the service instance
* Structure is documented below.
*/
appEngineHttpTarget?: pulumi.Input<inputs.cloudscheduler.JobAppEngineHttpTarget>;
/**
* The deadline for job attempts. If the request handler does not respond by this deadline then the request is
* cancelled and the attempt is marked as a DEADLINE_EXCEEDED failure. The failed attempt can be viewed in
* execution logs. Cloud Scheduler will retry the job according to the RetryConfig.
* The allowed duration for this deadline is:
* * For HTTP targets, between 15 seconds and 30 minutes.
* * For App Engine HTTP targets, between 15 seconds and 24 hours.
* * **Note**: For PubSub targets, this field is ignored - setting it will introduce an unresolvable diff.
* A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s"
*/
attemptDeadline?: pulumi.Input<string>;
/**
* A human-readable description for the job.
* This string must not contain more than 500 characters.
*/
description?: pulumi.Input<string>;
/**
* HTTP target.
* If the job providers a httpTarget the cron will
* send a request to the targeted url
* Structure is documented below.
*/
httpTarget?: pulumi.Input<inputs.cloudscheduler.JobHttpTarget>;
/**
* The name of the job.
*
*
* - - -
*/
name?: pulumi.Input<string>;
/**
* Sets the job to a paused state. Jobs default to being enabled when this property is not set.
*/
paused?: pulumi.Input<boolean>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string>;
/**
* Pub/Sub target
* If the job providers a Pub/Sub target the cron will publish
* a message to the provided topic
* Structure is documented below.
*/
pubsubTarget?: pulumi.Input<inputs.cloudscheduler.JobPubsubTarget>;
/**
* Region where the scheduler job resides. If it is not provided, this provider will use the provider default.
*/
region?: pulumi.Input<string>;
/**
* By default, if a job does not complete successfully,
* meaning that an acknowledgement is not received from the handler,
* then it will be retried with exponential backoff according to the settings
* Structure is documented below.
*/
retryConfig?: pulumi.Input<inputs.cloudscheduler.JobRetryConfig>;
/**
* Describes the schedule on which the job will be executed.
*/
schedule?: pulumi.Input<string>;
/**
* Specifies the time zone to be used in interpreting schedule.
* The value of this field must be a time zone name from the tz database.
*/
timeZone?: pulumi.Input<string>;
}