Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

WorkerRoute

Provides a Cloudflare worker route resource. A route will also require a cloudflare.WorkerScript. NOTE: This resource uses the Cloudflare account APIs. This requires setting the CLOUDFLARE_ACCOUNT_ID environment variable or account_id provider argument.

Example Usage

using Pulumi;
using Cloudflare = Pulumi.Cloudflare;

class MyStack : Stack
{
    public MyStack()
    {
        var myScript = new Cloudflare.WorkerScript("myScript", new Cloudflare.WorkerScriptArgs
        {
        });
        // see "cloudflare_worker_script" documentation ...
        // Runs the specified worker script for all URLs that match `example.com/*`
        var myRoute = new Cloudflare.WorkerRoute("myRoute", new Cloudflare.WorkerRouteArgs
        {
            ZoneId = "d41d8cd98f00b204e9800998ecf8427e",
            Pattern = "example.com/*",
            ScriptName = myScript.Name,
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-cloudflare/sdk/v2/go/cloudflare"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        myScript, err := cloudflare.NewWorkerScript(ctx, "myScript", nil)
        if err != nil {
            return err
        }
        _, err = cloudflare.NewWorkerRoute(ctx, "myRoute", &cloudflare.WorkerRouteArgs{
            ZoneId:     pulumi.String("d41d8cd98f00b204e9800998ecf8427e"),
            Pattern:    pulumi.String("example.com/*"),
            ScriptName: myScript.Name,
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_cloudflare as cloudflare

my_script = cloudflare.WorkerScript("myScript")
# see "cloudflare_worker_script" documentation ...
# Runs the specified worker script for all URLs that match `example.com/*`
my_route = cloudflare.WorkerRoute("myRoute",
    zone_id="d41d8cd98f00b204e9800998ecf8427e",
    pattern="example.com/*",
    script_name=my_script.name)
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";

const myScript = new cloudflare.WorkerScript("myScript", {});
// see "cloudflare_worker_script" documentation ...
// Runs the specified worker script for all URLs that match `example.com/*`
const myRoute = new cloudflare.WorkerRoute("myRoute", {
    zoneId: "d41d8cd98f00b204e9800998ecf8427e",
    pattern: "example.com/*",
    scriptName: myScript.name,
});

Create a WorkerRoute Resource

new WorkerRoute(name: string, args: WorkerRouteArgs, opts?: CustomResourceOptions);
def WorkerRoute(resource_name: str, opts: Optional[ResourceOptions] = None, pattern: Optional[str] = None, script_name: Optional[str] = None, zone_id: Optional[str] = None)
func NewWorkerRoute(ctx *Context, name string, args WorkerRouteArgs, opts ...ResourceOption) (*WorkerRoute, error)
public WorkerRoute(string name, WorkerRouteArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args WorkerRouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args WorkerRouteArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args WorkerRouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

WorkerRoute Resource Properties

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

Inputs

The WorkerRoute resource accepts the following input properties:

Pattern string

The route pattern

ZoneId string

The zone ID to add the route to.

ScriptName string

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

Pattern string

The route pattern

ZoneId string

The zone ID to add the route to.

ScriptName string

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

pattern string

The route pattern

zoneId string

The zone ID to add the route to.

scriptName string

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

pattern str

The route pattern

zone_id str

The zone ID to add the route to.

script_name str

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

Outputs

All input properties are implicitly available as output properties. Additionally, the WorkerRoute 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 WorkerRoute Resource

Get an existing WorkerRoute 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?: WorkerRouteState, opts?: CustomResourceOptions): WorkerRoute
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, pattern: Optional[str] = None, script_name: Optional[str] = None, zone_id: Optional[str] = None) -> WorkerRoute
func GetWorkerRoute(ctx *Context, name string, id IDInput, state *WorkerRouteState, opts ...ResourceOption) (*WorkerRoute, error)
public static WorkerRoute Get(string name, Input<string> id, WorkerRouteState? 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:

Pattern string

The route pattern

ScriptName string

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

ZoneId string

The zone ID to add the route to.

Pattern string

The route pattern

ScriptName string

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

ZoneId string

The zone ID to add the route to.

pattern string

The route pattern

scriptName string

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

zoneId string

The zone ID to add the route to.

pattern str

The route pattern

script_name str

Which worker script to run for requests that match the route pattern. If script_name is empty, workers will be skipped for matching requests.

zone_id str

The zone ID to add the route to.

Import

Records can be imported using a composite ID formed of zone ID and route ID, e.g.

 $ pulumi import cloudflare:index/workerRoute:WorkerRoute default d41d8cd98f00b204e9800998ecf8427e/9a7806061c88ada191ed06f989cc3dac

where* d41d8cd98f00b204e9800998ecf8427e - zone ID * 9a7806061c88ada191ed06f989cc3dac - route ID as returned by API

Package Details

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