WorkerCronTrigger

Worker Cron Triggers allow users to map a cron expression to a Worker script using a ScheduledEvent listener that enables Workers to be executed on a schedule. Worker Cron Triggers are ideal for running periodic jobs for maintenance or calling third-party APIs to collect up-to-date data.

Example Usage

using System.IO;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleScript = new Cloudflare.WorkerScript("exampleScript", new Cloudflare.WorkerScriptArgs
        {
            Name = "example-script",
            Content = File.ReadAllText("path/to/my.js"),
        });
        var exampleTrigger = new Cloudflare.WorkerCronTrigger("exampleTrigger", new Cloudflare.WorkerCronTriggerArgs
        {
            ScriptName = exampleScript.Name,
            Schedules = 
            {
                "*/5 * * * *",
                "10 7 * * mon-fri",
            },
        });
    }

}

Coming soon!

import pulumi
import pulumi_cloudflare as cloudflare

example_script = cloudflare.WorkerScript("exampleScript",
    name="example-script",
    content=(lambda path: open(path).read())("path/to/my.js"))
example_trigger = cloudflare.WorkerCronTrigger("exampleTrigger",
    script_name=example_script.name,
    schedules=[
        "*/5 * * * *",
        "10 7 * * mon-fri",
    ])
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
import * from "fs";

const exampleScript = new cloudflare.WorkerScript("exampleScript", {
    name: "example-script",
    content: fs.readFileSync("path/to/my.js"),
});
const exampleTrigger = new cloudflare.WorkerCronTrigger("exampleTrigger", {
    scriptName: exampleScript.name,
    schedules: [
        "*/5 * * * *",
        "10 7 * * mon-fri",
    ],
});

Create a WorkerCronTrigger Resource

new WorkerCronTrigger(name: string, args: WorkerCronTriggerArgs, opts?: CustomResourceOptions);
@overload
def WorkerCronTrigger(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      schedules: Optional[Sequence[str]] = None,
                      script_name: Optional[str] = None)
@overload
def WorkerCronTrigger(resource_name: str,
                      args: WorkerCronTriggerArgs,
                      opts: Optional[ResourceOptions] = None)
func NewWorkerCronTrigger(ctx *Context, name string, args WorkerCronTriggerArgs, opts ...ResourceOption) (*WorkerCronTrigger, error)
public WorkerCronTrigger(string name, WorkerCronTriggerArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args WorkerCronTriggerArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args WorkerCronTriggerArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args WorkerCronTriggerArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args WorkerCronTriggerArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

WorkerCronTrigger Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The WorkerCronTrigger resource accepts the following input properties:

Schedules List<string>
List of cron expressions to execute the Worker Script
ScriptName string
Worker script to target for the schedules
Schedules []string
List of cron expressions to execute the Worker Script
ScriptName string
Worker script to target for the schedules
schedules string[]
List of cron expressions to execute the Worker Script
scriptName string
Worker script to target for the schedules
schedules Sequence[str]
List of cron expressions to execute the Worker Script
script_name str
Worker script to target for the schedules

Outputs

All input properties are implicitly available as output properties. Additionally, the WorkerCronTrigger resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing WorkerCronTrigger Resource

Get an existing WorkerCronTrigger resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: WorkerCronTriggerState, opts?: CustomResourceOptions): WorkerCronTrigger
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        schedules: Optional[Sequence[str]] = None,
        script_name: Optional[str] = None) -> WorkerCronTrigger
func GetWorkerCronTrigger(ctx *Context, name string, id IDInput, state *WorkerCronTriggerState, opts ...ResourceOption) (*WorkerCronTrigger, error)
public static WorkerCronTrigger Get(string name, Input<string> id, WorkerCronTriggerState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Schedules List<string>
List of cron expressions to execute the Worker Script
ScriptName string
Worker script to target for the schedules
Schedules []string
List of cron expressions to execute the Worker Script
ScriptName string
Worker script to target for the schedules
schedules string[]
List of cron expressions to execute the Worker Script
scriptName string
Worker script to target for the schedules
schedules Sequence[str]
List of cron expressions to execute the Worker Script
script_name str
Worker script to target for the schedules

Import

Worker Cron Triggers can be imported using the script name of the Worker they are targeting.

 $ pulumi import cloudflare:index/workerCronTrigger:WorkerCronTrigger example my-script

Package Details

Repository
https://github.com/pulumi/pulumi-cloudflare
License
Apache-2.0
Notes
This Pulumi package is based on the cloudflare Terraform Provider.