1. Packages
  2. Cloudflare
  3. API Docs
  4. WorkerRoute
Cloudflare v5.33.1 published on Wednesday, Jun 26, 2024 by Pulumi

cloudflare.WorkerRoute

Explore with Pulumi AI

cloudflare logo
Cloudflare v5.33.1 published on Wednesday, Jun 26, 2024 by Pulumi

    Provides a Cloudflare worker route resource. A route will also require a cloudflare.WorkerScript.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const myScript = new cloudflare.WorkerScript("my_script", {});
    // Runs the specified worker script for all URLs that match `example.com/*`
    const myRoute = new cloudflare.WorkerRoute("my_route", {
        zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
        pattern: "example.com/*",
        scriptName: myScript.name,
    });
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    my_script = cloudflare.WorkerScript("my_script")
    # Runs the specified worker script for all URLs that match `example.com/*`
    my_route = cloudflare.WorkerRoute("my_route",
        zone_id="0da42c8d2132a9ddaf714f9e7c920711",
        pattern="example.com/*",
        script_name=my_script.name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myScript, err := cloudflare.NewWorkerScript(ctx, "my_script", nil)
    		if err != nil {
    			return err
    		}
    		// Runs the specified worker script for all URLs that match `example.com/*`
    		_, err = cloudflare.NewWorkerRoute(ctx, "my_route", &cloudflare.WorkerRouteArgs{
    			ZoneId:     pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
    			Pattern:    pulumi.String("example.com/*"),
    			ScriptName: myScript.Name,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var myScript = new Cloudflare.WorkerScript("my_script");
    
        // Runs the specified worker script for all URLs that match `example.com/*`
        var myRoute = new Cloudflare.WorkerRoute("my_route", new()
        {
            ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
            Pattern = "example.com/*",
            ScriptName = myScript.Name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.WorkerScript;
    import com.pulumi.cloudflare.WorkerRoute;
    import com.pulumi.cloudflare.WorkerRouteArgs;
    import java.util.List;
    import java.util.ArrayList;
    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 myScript = new WorkerScript("myScript");
    
            // Runs the specified worker script for all URLs that match `example.com/*`
            var myRoute = new WorkerRoute("myRoute", WorkerRouteArgs.builder()
                .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
                .pattern("example.com/*")
                .scriptName(myScript.name())
                .build());
    
        }
    }
    
    resources:
      # Runs the specified worker script for all URLs that match `example.com/*`
      myRoute:
        type: cloudflare:WorkerRoute
        name: my_route
        properties:
          zoneId: 0da42c8d2132a9ddaf714f9e7c920711
          pattern: example.com/*
          scriptName: ${myScript.name}
      myScript:
        type: cloudflare:WorkerScript
        name: my_script
    

    Create WorkerRoute Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new WorkerRoute(name: string, args: WorkerRouteArgs, opts?: CustomResourceOptions);
    @overload
    def WorkerRoute(resource_name: str,
                    args: WorkerRouteArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def WorkerRoute(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    pattern: Optional[str] = None,
                    zone_id: Optional[str] = None,
                    script_name: Optional[str] = None)
    func NewWorkerRoute(ctx *Context, name string, args WorkerRouteArgs, opts ...ResourceOption) (*WorkerRoute, error)
    public WorkerRoute(string name, WorkerRouteArgs args, CustomResourceOptions? opts = null)
    public WorkerRoute(String name, WorkerRouteArgs args)
    public WorkerRoute(String name, WorkerRouteArgs args, CustomResourceOptions options)
    
    type: cloudflare:WorkerRoute
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    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.
    args WorkerRouteArgs
    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 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.
    name String
    The unique name of the resource.
    args WorkerRouteArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var workerRouteResource = new Cloudflare.WorkerRoute("workerRouteResource", new()
    {
        Pattern = "string",
        ZoneId = "string",
        ScriptName = "string",
    });
    
    example, err := cloudflare.NewWorkerRoute(ctx, "workerRouteResource", &cloudflare.WorkerRouteArgs{
    	Pattern:    pulumi.String("string"),
    	ZoneId:     pulumi.String("string"),
    	ScriptName: pulumi.String("string"),
    })
    
    var workerRouteResource = new WorkerRoute("workerRouteResource", WorkerRouteArgs.builder()
        .pattern("string")
        .zoneId("string")
        .scriptName("string")
        .build());
    
    worker_route_resource = cloudflare.WorkerRoute("workerRouteResource",
        pattern="string",
        zone_id="string",
        script_name="string")
    
    const workerRouteResource = new cloudflare.WorkerRoute("workerRouteResource", {
        pattern: "string",
        zoneId: "string",
        scriptName: "string",
    });
    
    type: cloudflare:WorkerRoute
    properties:
        pattern: string
        scriptName: string
        zoneId: string
    

    WorkerRoute Resource Properties

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

    Inputs

    The WorkerRoute resource accepts the following input properties:

    Pattern string
    The route pattern to associate the Worker with.
    ZoneId string
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    ScriptName string
    Worker script name to invoke for requests that match the route pattern.
    Pattern string
    The route pattern to associate the Worker with.
    ZoneId string
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    ScriptName string
    Worker script name to invoke for requests that match the route pattern.
    pattern String
    The route pattern to associate the Worker with.
    zoneId String
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    scriptName String
    Worker script name to invoke for requests that match the route pattern.
    pattern string
    The route pattern to associate the Worker with.
    zoneId string
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    scriptName string
    Worker script name to invoke for requests that match the route pattern.
    pattern str
    The route pattern to associate the Worker with.
    zone_id str
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    script_name str
    Worker script name to invoke for requests that match the route pattern.
    pattern String
    The route pattern to associate the Worker with.
    zoneId String
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    scriptName String
    Worker script name to invoke for requests that match the route pattern.

    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 string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up 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)
    public static WorkerRoute get(String name, Output<String> id, WorkerRouteState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    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 to associate the Worker with.
    ScriptName string
    Worker script name to invoke for requests that match the route pattern.
    ZoneId string
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    Pattern string
    The route pattern to associate the Worker with.
    ScriptName string
    Worker script name to invoke for requests that match the route pattern.
    ZoneId string
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    pattern String
    The route pattern to associate the Worker with.
    scriptName String
    Worker script name to invoke for requests that match the route pattern.
    zoneId String
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    pattern string
    The route pattern to associate the Worker with.
    scriptName string
    Worker script name to invoke for requests that match the route pattern.
    zoneId string
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    pattern str
    The route pattern to associate the Worker with.
    script_name str
    Worker script name to invoke for requests that match the route pattern.
    zone_id str
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.
    pattern String
    The route pattern to associate the Worker with.
    scriptName String
    Worker script name to invoke for requests that match the route pattern.
    zoneId String
    The zone identifier to target for the resource. Modifying this attribute will force creation of a new resource.

    Import

    $ pulumi import cloudflare:index/workerRoute:WorkerRoute example <zone_id>/<route_id>
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Cloudflare v5.33.1 published on Wednesday, Jun 26, 2024 by Pulumi