Job class
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
- How-to Guides
- Official Documentation
Example Usage
Scheduler Job Pubsub
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),
},
});
import pulumi
import pulumi_gcp as gcp
import pulumi_std as std
topic = gcp.pubsub.Topic("topic", name="job-topic")
job = gcp.cloudscheduler.Job("job",
name="test-job",
description="test job",
schedule="*/2 * * * *",
pubsub_target={
"topic_name": topic.id,
"data": std.base64encode(input="test").result,
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var topic = new Gcp.PubSub.Topic("topic", new()
{
Name = "job-topic",
});
var job = new Gcp.CloudScheduler.Job("job", new()
{
Name = "test-job",
Description = "test job",
Schedule = "*/2 * * * *",
PubsubTarget = new Gcp.CloudScheduler.Inputs.JobPubsubTargetArgs
{
TopicName = topic.Id,
Data = Std.Base64encode.Invoke(new()
{
Input = "test",
}).Apply(invoke => invoke.Result),
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudscheduler"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/pubsub"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
topic, err := pubsub.NewTopic(ctx, "topic", &pubsub.TopicArgs{
Name: pulumi.String("job-topic"),
})
if err != nil {
return err
}
invokeBase64encode, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "test",
}, nil)
if err != nil {
return err
}
_, err = cloudscheduler.NewJob(ctx, "job", &cloudscheduler.JobArgs{
Name: pulumi.String("test-job"),
Description: pulumi.String("test job"),
Schedule: pulumi.String("*/2 * * * *"),
PubsubTarget: &cloudscheduler.JobPubsubTargetArgs{
TopicName: topic.ID().ToIDOutput().ToStringOutput(),
Data: pulumi.String(invokeBase64encode.Result),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
std = {
source = "pulumi/std"
}
}
}
resource "gcp_pubsub_topic" "topic" {
name = "job-topic"
}
resource "gcp_cloudscheduler_job" "job" {
name = "test-job"
description = "test job"
schedule = "*/2 * * * *"
pubsub_target = {
topic_name = gcp_pubsub_topic.topic.id
data = base64encode("test")
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.pubsub.Topic;
import com.pulumi.gcp.pubsub.TopicArgs;
import com.pulumi.gcp.cloudscheduler.Job;
import com.pulumi.gcp.cloudscheduler.JobArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobPubsubTargetArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.Base64encodeArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var topic = new Topic("topic", TopicArgs.builder()
.name("job-topic")
.build());
var job = new Job("job", JobArgs.builder()
.name("test-job")
.description("test job")
.schedule("*/2 * * * *")
.pubsubTarget(JobPubsubTargetArgs.builder()
.topicName(topic.id())
.data(StdFunctions.base64encode(Base64encodeArgs.builder()
.input("test")
.build()).result())
.build())
.build());
}
}
resources:
topic:
type: gcp:pubsub:Topic
properties:
name: job-topic
job:
type: gcp:cloudscheduler:Job
properties:
name: test-job
description: test job
schedule: '*/2 * * * *'
pubsubTarget:
topicName: ${topic.id}
data:
fn::invoke:
function: std:base64encode
arguments:
input: test
return: result
Scheduler Job Http
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",
},
},
});
import pulumi
import pulumi_gcp as gcp
import pulumi_std as std
job = gcp.cloudscheduler.Job("job",
name="test-job",
description="test http job",
schedule="*/8 * * * *",
time_zone="America/New_York",
attempt_deadline="320s",
retry_config={
"retry_count": 1,
},
http_target={
"http_method": "POST",
"uri": "https://example.com/",
"body": std.base64encode(input="{\"foo\":\"bar\"}").result,
"headers": {
"Content-Type": "application/json",
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var job = new Gcp.CloudScheduler.Job("job", new()
{
Name = "test-job",
Description = "test http job",
Schedule = "*/8 * * * *",
TimeZone = "America/New_York",
AttemptDeadline = "320s",
RetryConfig = new Gcp.CloudScheduler.Inputs.JobRetryConfigArgs
{
RetryCount = 1,
},
HttpTarget = new Gcp.CloudScheduler.Inputs.JobHttpTargetArgs
{
HttpMethod = "POST",
Uri = "https://example.com/",
Body = Std.Base64encode.Invoke(new()
{
Input = "{\"foo\":\"bar\"}",
}).Apply(invoke => invoke.Result),
Headers =
{
{ "Content-Type", "application/json" },
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudscheduler"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeBase64encode, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "{\"foo\":\"bar\"}",
}, nil)
if err != nil {
return err
}
_, err = cloudscheduler.NewJob(ctx, "job", &cloudscheduler.JobArgs{
Name: pulumi.String("test-job"),
Description: pulumi.String("test http job"),
Schedule: pulumi.String("*/8 * * * *"),
TimeZone: pulumi.String("America/New_York"),
AttemptDeadline: pulumi.String("320s"),
RetryConfig: &cloudscheduler.JobRetryConfigArgs{
RetryCount: pulumi.Int(1),
},
HttpTarget: &cloudscheduler.JobHttpTargetArgs{
HttpMethod: pulumi.String("POST"),
Uri: pulumi.String("https://example.com/"),
Body: pulumi.String(invokeBase64encode.Result),
Headers: pulumi.StringMap{
"Content-Type": pulumi.String("application/json"),
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
std = {
source = "pulumi/std"
}
}
}
resource "gcp_cloudscheduler_job" "job" {
name = "test-job"
description = "test http job"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"
retry_config = {
retry_count = 1
}
http_target = {
http_method = "POST"
uri = "https://example.com/"
body = base64encode("{\"foo\":\"bar\"}")
headers = {
"Content-Type" = "application/json"
}
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.cloudscheduler.Job;
import com.pulumi.gcp.cloudscheduler.JobArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobRetryConfigArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.Base64encodeArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var job = new Job("job", JobArgs.builder()
.name("test-job")
.description("test http job")
.schedule("*/8 * * * *")
.timeZone("America/New_York")
.attemptDeadline("320s")
.retryConfig(JobRetryConfigArgs.builder()
.retryCount(1)
.build())
.httpTarget(JobHttpTargetArgs.builder()
.httpMethod("POST")
.uri("https://example.com/")
.body(StdFunctions.base64encode(Base64encodeArgs.builder()
.input("{\"foo\":\"bar\"}")
.build()).result())
.headers(Map.of("Content-Type", "application/json"))
.build())
.build());
}
}
resources:
job:
type: gcp:cloudscheduler:Job
properties:
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:
fn::invoke:
function: std:base64encode
arguments:
input: '{"foo":"bar"}'
return: result
headers:
Content-Type: application/json
Scheduler Job Paused
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",
},
},
});
import pulumi
import pulumi_gcp as gcp
import pulumi_std as std
job = gcp.cloudscheduler.Job("job",
paused=True,
name="test-job",
description="test http job with updated fields",
schedule="*/8 * * * *",
time_zone="America/New_York",
attempt_deadline="320s",
retry_config={
"retry_count": 1,
},
http_target={
"http_method": "POST",
"uri": "https://example.com/ping",
"body": std.base64encode(input="{\"foo\":\"bar\"}").result,
"headers": {
"Content-Type": "application/json",
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var job = new Gcp.CloudScheduler.Job("job", new()
{
Paused = true,
Name = "test-job",
Description = "test http job with updated fields",
Schedule = "*/8 * * * *",
TimeZone = "America/New_York",
AttemptDeadline = "320s",
RetryConfig = new Gcp.CloudScheduler.Inputs.JobRetryConfigArgs
{
RetryCount = 1,
},
HttpTarget = new Gcp.CloudScheduler.Inputs.JobHttpTargetArgs
{
HttpMethod = "POST",
Uri = "https://example.com/ping",
Body = Std.Base64encode.Invoke(new()
{
Input = "{\"foo\":\"bar\"}",
}).Apply(invoke => invoke.Result),
Headers =
{
{ "Content-Type", "application/json" },
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudscheduler"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeBase64encode, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "{\"foo\":\"bar\"}",
}, nil)
if err != nil {
return err
}
_, err = cloudscheduler.NewJob(ctx, "job", &cloudscheduler.JobArgs{
Paused: pulumi.Bool(true),
Name: pulumi.String("test-job"),
Description: pulumi.String("test http job with updated fields"),
Schedule: pulumi.String("*/8 * * * *"),
TimeZone: pulumi.String("America/New_York"),
AttemptDeadline: pulumi.String("320s"),
RetryConfig: &cloudscheduler.JobRetryConfigArgs{
RetryCount: pulumi.Int(1),
},
HttpTarget: &cloudscheduler.JobHttpTargetArgs{
HttpMethod: pulumi.String("POST"),
Uri: pulumi.String("https://example.com/ping"),
Body: pulumi.String(invokeBase64encode.Result),
Headers: pulumi.StringMap{
"Content-Type": pulumi.String("application/json"),
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
std = {
source = "pulumi/std"
}
}
}
resource "gcp_cloudscheduler_job" "job" {
paused = true
name = "test-job"
description = "test http job with updated fields"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"
retry_config = {
retry_count = 1
}
http_target = {
http_method = "POST"
uri = "https://example.com/ping"
body = base64encode("{\"foo\":\"bar\"}")
headers = {
"Content-Type" = "application/json"
}
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.cloudscheduler.Job;
import com.pulumi.gcp.cloudscheduler.JobArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobRetryConfigArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.Base64encodeArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var job = new Job("job", JobArgs.builder()
.paused(true)
.name("test-job")
.description("test http job with updated fields")
.schedule("*/8 * * * *")
.timeZone("America/New_York")
.attemptDeadline("320s")
.retryConfig(JobRetryConfigArgs.builder()
.retryCount(1)
.build())
.httpTarget(JobHttpTargetArgs.builder()
.httpMethod("POST")
.uri("https://example.com/ping")
.body(StdFunctions.base64encode(Base64encodeArgs.builder()
.input("{\"foo\":\"bar\"}")
.build()).result())
.headers(Map.of("Content-Type", "application/json"))
.build())
.build());
}
}
resources:
job:
type: gcp:cloudscheduler:Job
properties:
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:
fn::invoke:
function: std:base64encode
arguments:
input: '{"foo":"bar"}'
return: result
headers:
Content-Type: application/json
Scheduler Job App Engine
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",
},
});
import pulumi
import pulumi_gcp as gcp
job = gcp.cloudscheduler.Job("job",
name="test-job",
schedule="*/4 * * * *",
description="test app engine job",
time_zone="Europe/London",
attempt_deadline="320s",
retry_config={
"min_backoff_duration": "1s",
"max_retry_duration": "10s",
"max_doublings": 2,
"retry_count": 3,
},
app_engine_http_target={
"http_method": "POST",
"app_engine_routing": {
"service": "web",
"version": "prod",
"instance": "my-instance-001",
},
"relative_uri": "/ping",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var job = new Gcp.CloudScheduler.Job("job", new()
{
Name = "test-job",
Schedule = "*/4 * * * *",
Description = "test app engine job",
TimeZone = "Europe/London",
AttemptDeadline = "320s",
RetryConfig = new Gcp.CloudScheduler.Inputs.JobRetryConfigArgs
{
MinBackoffDuration = "1s",
MaxRetryDuration = "10s",
MaxDoublings = 2,
RetryCount = 3,
},
AppEngineHttpTarget = new Gcp.CloudScheduler.Inputs.JobAppEngineHttpTargetArgs
{
HttpMethod = "POST",
AppEngineRouting = new Gcp.CloudScheduler.Inputs.JobAppEngineHttpTargetAppEngineRoutingArgs
{
Service = "web",
Version = "prod",
Instance = "my-instance-001",
},
RelativeUri = "/ping",
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudscheduler"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudscheduler.NewJob(ctx, "job", &cloudscheduler.JobArgs{
Name: pulumi.String("test-job"),
Schedule: pulumi.String("*/4 * * * *"),
Description: pulumi.String("test app engine job"),
TimeZone: pulumi.String("Europe/London"),
AttemptDeadline: pulumi.String("320s"),
RetryConfig: &cloudscheduler.JobRetryConfigArgs{
MinBackoffDuration: pulumi.String("1s"),
MaxRetryDuration: pulumi.String("10s"),
MaxDoublings: pulumi.Int(2),
RetryCount: pulumi.Int(3),
},
AppEngineHttpTarget: &cloudscheduler.JobAppEngineHttpTargetArgs{
HttpMethod: pulumi.String("POST"),
AppEngineRouting: &cloudscheduler.JobAppEngineHttpTargetAppEngineRoutingArgs{
Service: pulumi.String("web"),
Version: pulumi.String("prod"),
Instance: pulumi.String("my-instance-001"),
},
RelativeUri: pulumi.String("/ping"),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_cloudscheduler_job" "job" {
name = "test-job"
schedule = "*/4 * * * *"
description = "test app engine job"
time_zone = "Europe/London"
attempt_deadline = "320s"
retry_config = {
min_backoff_duration = "1s"
max_retry_duration = "10s"
max_doublings = 2
retry_count = 3
}
app_engine_http_target = {
http_method = "POST"
app_engine_routing = {
service = "web"
version = "prod"
instance = "my-instance-001"
}
relative_uri = "/ping"
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.cloudscheduler.Job;
import com.pulumi.gcp.cloudscheduler.JobArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobRetryConfigArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobAppEngineHttpTargetArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobAppEngineHttpTargetAppEngineRoutingArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var job = new Job("job", JobArgs.builder()
.name("test-job")
.schedule("*/4 * * * *")
.description("test app engine job")
.timeZone("Europe/London")
.attemptDeadline("320s")
.retryConfig(JobRetryConfigArgs.builder()
.minBackoffDuration("1s")
.maxRetryDuration("10s")
.maxDoublings(2)
.retryCount(3)
.build())
.appEngineHttpTarget(JobAppEngineHttpTargetArgs.builder()
.httpMethod("POST")
.appEngineRouting(JobAppEngineHttpTargetAppEngineRoutingArgs.builder()
.service("web")
.version("prod")
.instance("my-instance-001")
.build())
.relativeUri("/ping")
.build())
.build());
}
}
resources:
job:
type: gcp:cloudscheduler:Job
properties:
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
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),
},
},
});
import pulumi
import pulumi_gcp as gcp
default = gcp.compute.get_default_service_account()
job = gcp.cloudscheduler.Job("job",
name="test-job",
description="test http job",
schedule="*/8 * * * *",
time_zone="America/New_York",
attempt_deadline="320s",
http_target={
"http_method": "GET",
"uri": "https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs",
"oauth_token": {
"service_account_email": default.email,
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = Gcp.Compute.GetDefaultServiceAccount.Invoke();
var job = new Gcp.CloudScheduler.Job("job", new()
{
Name = "test-job",
Description = "test http job",
Schedule = "*/8 * * * *",
TimeZone = "America/New_York",
AttemptDeadline = "320s",
HttpTarget = new Gcp.CloudScheduler.Inputs.JobHttpTargetArgs
{
HttpMethod = "GET",
Uri = "https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs",
OauthToken = new Gcp.CloudScheduler.Inputs.JobHttpTargetOauthTokenArgs
{
ServiceAccountEmail = @default.Apply(@default => @default.Apply(getDefaultServiceAccountResult => getDefaultServiceAccountResult.Email)),
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudscheduler"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := compute.GetDefaultServiceAccount(ctx, &compute.GetDefaultServiceAccountArgs{}, nil)
if err != nil {
return err
}
_, err = cloudscheduler.NewJob(ctx, "job", &cloudscheduler.JobArgs{
Name: pulumi.String("test-job"),
Description: pulumi.String("test http job"),
Schedule: pulumi.String("*/8 * * * *"),
TimeZone: pulumi.String("America/New_York"),
AttemptDeadline: pulumi.String("320s"),
HttpTarget: &cloudscheduler.JobHttpTargetArgs{
HttpMethod: pulumi.String("GET"),
Uri: pulumi.String("https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs"),
OauthToken: &cloudscheduler.JobHttpTargetOauthTokenArgs{
ServiceAccountEmail: pulumi.String(_default.Email),
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
data "gcp_compute_getdefaultserviceaccount" "default" {
}
resource "gcp_cloudscheduler_job" "job" {
name = "test-job"
description = "test http job"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"
http_target = {
http_method = "GET"
uri = "https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs"
oauth_token = {
service_account_email = data.gcp_compute_getdefaultserviceaccount.default.email
}
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetDefaultServiceAccountArgs;
import com.pulumi.gcp.cloudscheduler.Job;
import com.pulumi.gcp.cloudscheduler.JobArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetOauthTokenArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var default = ComputeFunctions.getDefaultServiceAccount(GetDefaultServiceAccountArgs.builder()
.build());
var job = new Job("job", JobArgs.builder()
.name("test-job")
.description("test http job")
.schedule("*/8 * * * *")
.timeZone("America/New_York")
.attemptDeadline("320s")
.httpTarget(JobHttpTargetArgs.builder()
.httpMethod("GET")
.uri("https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs")
.oauthToken(JobHttpTargetOauthTokenArgs.builder()
.serviceAccountEmail(default_.email())
.build())
.build())
.build());
}
}
resources:
job:
type: gcp:cloudscheduler:Job
properties:
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.email}
variables:
default:
fn::invoke:
function: gcp:compute:getDefaultServiceAccount
arguments: {}
Scheduler Job Oidc
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 pulumi
import pulumi_gcp as gcp
default = gcp.compute.get_default_service_account()
job = gcp.cloudscheduler.Job("job",
name="test-job",
description="test http job",
schedule="*/8 * * * *",
time_zone="America/New_York",
attempt_deadline="320s",
http_target={
"http_method": "GET",
"uri": "https://example.com/ping",
"oidc_token": {
"service_account_email": default.email,
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = Gcp.Compute.GetDefaultServiceAccount.Invoke();
var job = new Gcp.CloudScheduler.Job("job", new()
{
Name = "test-job",
Description = "test http job",
Schedule = "*/8 * * * *",
TimeZone = "America/New_York",
AttemptDeadline = "320s",
HttpTarget = new Gcp.CloudScheduler.Inputs.JobHttpTargetArgs
{
HttpMethod = "GET",
Uri = "https://example.com/ping",
OidcToken = new Gcp.CloudScheduler.Inputs.JobHttpTargetOidcTokenArgs
{
ServiceAccountEmail = @default.Apply(@default => @default.Apply(getDefaultServiceAccountResult => getDefaultServiceAccountResult.Email)),
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudscheduler"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := compute.GetDefaultServiceAccount(ctx, &compute.GetDefaultServiceAccountArgs{}, nil)
if err != nil {
return err
}
_, err = cloudscheduler.NewJob(ctx, "job", &cloudscheduler.JobArgs{
Name: pulumi.String("test-job"),
Description: pulumi.String("test http job"),
Schedule: pulumi.String("*/8 * * * *"),
TimeZone: pulumi.String("America/New_York"),
AttemptDeadline: pulumi.String("320s"),
HttpTarget: &cloudscheduler.JobHttpTargetArgs{
HttpMethod: pulumi.String("GET"),
Uri: pulumi.String("https://example.com/ping"),
OidcToken: &cloudscheduler.JobHttpTargetOidcTokenArgs{
ServiceAccountEmail: pulumi.String(_default.Email),
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
data "gcp_compute_getdefaultserviceaccount" "default" {
}
resource "gcp_cloudscheduler_job" "job" {
name = "test-job"
description = "test http job"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"
http_target = {
http_method = "GET"
uri = "https://example.com/ping"
oidc_token = {
service_account_email = data.gcp_compute_getdefaultserviceaccount.default.email
}
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetDefaultServiceAccountArgs;
import com.pulumi.gcp.cloudscheduler.Job;
import com.pulumi.gcp.cloudscheduler.JobArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetArgs;
import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetOidcTokenArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var default = ComputeFunctions.getDefaultServiceAccount(GetDefaultServiceAccountArgs.builder()
.build());
var job = new Job("job", JobArgs.builder()
.name("test-job")
.description("test http job")
.schedule("*/8 * * * *")
.timeZone("America/New_York")
.attemptDeadline("320s")
.httpTarget(JobHttpTargetArgs.builder()
.httpMethod("GET")
.uri("https://example.com/ping")
.oidcToken(JobHttpTargetOidcTokenArgs.builder()
.serviceAccountEmail(default_.email())
.build())
.build())
.build());
}
}
resources:
job:
type: gcp:cloudscheduler:Job
properties:
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.email}
variables:
default:
fn::invoke:
function: gcp:compute:getDefaultServiceAccount
arguments: {}
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:
$ pulumi import gcp:cloudscheduler/job:Job default projects/{{project}}/locations/{{region}}/jobs/{{name}}
$ pulumi import gcp:cloudscheduler/job:Job default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:cloudscheduler/job:Job default {{region}}/{{name}}
$ pulumi import gcp:cloudscheduler/job:Job default {{name}}
Constructors
- Job(String name, {JobArgs? args, CustomResourceOptions? options})
-
Creates a new Job.
nameThe Pulumi resource name.argsArguments used to configure this Job. The set of arguments for Job.optionsResource options controlling this resource's behavior. - Job.reference(String urn)
- Creates a typed reference to an existing Job resource.
Properties
-
appEngineHttpTarget
↔ Output<
JobAppEngineHttpTarget?> -
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.
latefinal
-
attemptDeadline
↔ Output<
String?> -
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:
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
description
↔ Output<
String?> -
A human-readable description for the job.
This string must not contain more than 500 characters.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
httpTarget
↔ Output<
JobHttpTarget?> -
HTTP target.
If the job providers a httpTarget the cron will
send a request to the targeted url
Structure is documented below.
latefinal
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
The name of the job.
latefinal
-
paused
↔ Output<
bool> -
Sets the job to a paused state. Jobs default to being enabled when this property is not set.
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
pubsubTarget
↔ Output<
JobPubsubTarget?> -
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.
latefinal
-
region
↔ Output<
String> -
Region where the scheduler job resides. If it is not provided, this provider will use the provider default.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
retryConfig
↔ Output<
JobRetryConfig?> -
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.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
schedule
↔ Output<
String?> -
Describes the schedule on which the job will be executed.
latefinal
-
state
↔ Output<
String> -
State of the job.
latefinal
-
timeZone
↔ 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.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited