1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. WorkerScript
Viewing docs for Cloudflare v4.16.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
cloudflare logo
Viewing docs for Cloudflare v4.16.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Provides a Cloudflare worker script resource. In order for a script to be active, you’ll also need to setup a cloudflare.WorkerRoute.

    This resource uses the Cloudflare account APIs. This requires setting the CLOUDFLARE_ACCOUNT_ID environment variable or account_id provider argument.

    Example Usage

    using System;
    using System.Collections.Generic;
    using System.IO;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    	private static string ReadFileBase64(string path) {
    		return Convert.ToBase64String(Encoding.UTF8.GetBytes(File.ReadAllText(path)))
    	}
    
    return await Deployment.RunAsync(() => 
    {
        var myNamespace = new Cloudflare.WorkersKvNamespace("myNamespace", new()
        {
            AccountId = "f037e56e89293a057740de681ac9abbe",
            Title = "example",
        });
    
        // Sets the script with the name "script_1"
        var myScript = new Cloudflare.WorkerScript("myScript", new()
        {
            AccountId = "f037e56e89293a057740de681ac9abbe",
            Name = "script_1",
            Content = File.ReadAllText("script.js"),
            KvNamespaceBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptKvNamespaceBindingArgs
                {
                    Name = "MY_EXAMPLE_KV_NAMESPACE",
                    NamespaceId = myNamespace.Id,
                },
            },
            PlainTextBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptPlainTextBindingArgs
                {
                    Name = "MY_EXAMPLE_PLAIN_TEXT",
                    Text = "foobar",
                },
            },
            SecretTextBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptSecretTextBindingArgs
                {
                    Name = "MY_EXAMPLE_SECRET_TEXT",
                    Text = @var.Secret_foo_value,
                },
            },
            WebassemblyBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptWebassemblyBindingArgs
                {
                    Name = "MY_EXAMPLE_WASM",
                    Module = ReadFileBase64("example.wasm"),
                },
            },
            ServiceBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptServiceBindingArgs
                {
                    Name = "MY_SERVICE_BINDING",
                    Service = "MY_SERVICE",
                    Environment = "production",
                },
            },
            R2BucketBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptR2BucketBindingArgs
                {
                    Name = "MY_BUCKET",
                    BucketName = "MY_BUCKET_NAME",
                },
            },
            AnalyticsEngineBindings = new[]
            {
                new Cloudflare.Inputs.WorkerScriptAnalyticsEngineBindingArgs
                {
                    Name = "MY_DATASET",
                    Dataset = "dataset1",
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"encoding/base64"
    	"os"
    
    	"github.com/pulumi/pulumi-cloudflare/sdk/v4/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func filebase64OrPanic(path string) pulumi.StringPtrInput {
    	if fileData, err := os.ReadFile(path); err == nil {
    		return pulumi.String(base64.StdEncoding.EncodeToString(fileData[:]))
    	} else {
    		panic(err.Error())
    	}
    }
    
    func readFileOrPanic(path string) pulumi.StringPtrInput {
    	data, err := os.ReadFile(path)
    	if err != nil {
    		panic(err.Error())
    	}
    	return pulumi.String(string(data))
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myNamespace, err := cloudflare.NewWorkersKvNamespace(ctx, "myNamespace", &cloudflare.WorkersKvNamespaceArgs{
    			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
    			Title:     pulumi.String("example"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = cloudflare.NewWorkerScript(ctx, "myScript", &cloudflare.WorkerScriptArgs{
    			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
    			Name:      pulumi.String("script_1"),
    			Content:   readFileOrPanic("script.js"),
    			KvNamespaceBindings: cloudflare.WorkerScriptKvNamespaceBindingArray{
    				&cloudflare.WorkerScriptKvNamespaceBindingArgs{
    					Name:        pulumi.String("MY_EXAMPLE_KV_NAMESPACE"),
    					NamespaceId: myNamespace.ID(),
    				},
    			},
    			PlainTextBindings: cloudflare.WorkerScriptPlainTextBindingArray{
    				&cloudflare.WorkerScriptPlainTextBindingArgs{
    					Name: pulumi.String("MY_EXAMPLE_PLAIN_TEXT"),
    					Text: pulumi.String("foobar"),
    				},
    			},
    			SecretTextBindings: cloudflare.WorkerScriptSecretTextBindingArray{
    				&cloudflare.WorkerScriptSecretTextBindingArgs{
    					Name: pulumi.String("MY_EXAMPLE_SECRET_TEXT"),
    					Text: pulumi.Any(_var.Secret_foo_value),
    				},
    			},
    			WebassemblyBindings: cloudflare.WorkerScriptWebassemblyBindingArray{
    				&cloudflare.WorkerScriptWebassemblyBindingArgs{
    					Name:   pulumi.String("MY_EXAMPLE_WASM"),
    					Module: filebase64OrPanic("example.wasm"),
    				},
    			},
    			ServiceBindings: cloudflare.WorkerScriptServiceBindingArray{
    				&cloudflare.WorkerScriptServiceBindingArgs{
    					Name:        pulumi.String("MY_SERVICE_BINDING"),
    					Service:     pulumi.String("MY_SERVICE"),
    					Environment: pulumi.String("production"),
    				},
    			},
    			R2BucketBindings: cloudflare.WorkerScriptR2BucketBindingArray{
    				&cloudflare.WorkerScriptR2BucketBindingArgs{
    					Name:       pulumi.String("MY_BUCKET"),
    					BucketName: pulumi.String("MY_BUCKET_NAME"),
    				},
    			},
    			AnalyticsEngineBindings: cloudflare.WorkerScriptAnalyticsEngineBindingArray{
    				&cloudflare.WorkerScriptAnalyticsEngineBindingArgs{
    					Name:    pulumi.String("MY_DATASET"),
    					Dataset: pulumi.String("dataset1"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.WorkersKvNamespace;
    import com.pulumi.cloudflare.WorkersKvNamespaceArgs;
    import com.pulumi.cloudflare.WorkerScript;
    import com.pulumi.cloudflare.WorkerScriptArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptKvNamespaceBindingArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptPlainTextBindingArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptSecretTextBindingArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptWebassemblyBindingArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptServiceBindingArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptR2BucketBindingArgs;
    import com.pulumi.cloudflare.inputs.WorkerScriptAnalyticsEngineBindingArgs;
    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 myNamespace = new WorkersKvNamespace("myNamespace", WorkersKvNamespaceArgs.builder()        
                .accountId("f037e56e89293a057740de681ac9abbe")
                .title("example")
                .build());
    
            var myScript = new WorkerScript("myScript", WorkerScriptArgs.builder()        
                .accountId("f037e56e89293a057740de681ac9abbe")
                .name("script_1")
                .content(Files.readString(Paths.get("script.js")))
                .kvNamespaceBindings(WorkerScriptKvNamespaceBindingArgs.builder()
                    .name("MY_EXAMPLE_KV_NAMESPACE")
                    .namespaceId(myNamespace.id())
                    .build())
                .plainTextBindings(WorkerScriptPlainTextBindingArgs.builder()
                    .name("MY_EXAMPLE_PLAIN_TEXT")
                    .text("foobar")
                    .build())
                .secretTextBindings(WorkerScriptSecretTextBindingArgs.builder()
                    .name("MY_EXAMPLE_SECRET_TEXT")
                    .text(var_.secret_foo_value())
                    .build())
                .webassemblyBindings(WorkerScriptWebassemblyBindingArgs.builder()
                    .name("MY_EXAMPLE_WASM")
                    .module(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("example.wasm"))))
                    .build())
                .serviceBindings(WorkerScriptServiceBindingArgs.builder()
                    .name("MY_SERVICE_BINDING")
                    .service("MY_SERVICE")
                    .environment("production")
                    .build())
                .r2BucketBindings(WorkerScriptR2BucketBindingArgs.builder()
                    .name("MY_BUCKET")
                    .bucketName("MY_BUCKET_NAME")
                    .build())
                .analyticsEngineBindings(WorkerScriptAnalyticsEngineBindingArgs.builder()
                    .name("MY_DATASET")
                    .dataset("dataset1")
                    .build())
                .build());
    
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    import * as fs from "fs";
    
    const myNamespace = new cloudflare.WorkersKvNamespace("myNamespace", {
        accountId: "f037e56e89293a057740de681ac9abbe",
        title: "example",
    });
    // Sets the script with the name "script_1"
    const myScript = new cloudflare.WorkerScript("myScript", {
        accountId: "f037e56e89293a057740de681ac9abbe",
        name: "script_1",
        content: fs.readFileSync("script.js"),
        kvNamespaceBindings: [{
            name: "MY_EXAMPLE_KV_NAMESPACE",
            namespaceId: myNamespace.id,
        }],
        plainTextBindings: [{
            name: "MY_EXAMPLE_PLAIN_TEXT",
            text: "foobar",
        }],
        secretTextBindings: [{
            name: "MY_EXAMPLE_SECRET_TEXT",
            text: _var.secret_foo_value,
        }],
        webassemblyBindings: [{
            name: "MY_EXAMPLE_WASM",
            module: Buffer.from(fs.readFileSync("example.wasm"), 'binary').toString('base64'),
        }],
        serviceBindings: [{
            name: "MY_SERVICE_BINDING",
            service: "MY_SERVICE",
            environment: "production",
        }],
        r2BucketBindings: [{
            name: "MY_BUCKET",
            bucketName: "MY_BUCKET_NAME",
        }],
        analyticsEngineBindings: [{
            name: "MY_DATASET",
            dataset: "dataset1",
        }],
    });
    
    import pulumi
    import base64
    import pulumi_cloudflare as cloudflare
    
    my_namespace = cloudflare.WorkersKvNamespace("myNamespace",
        account_id="f037e56e89293a057740de681ac9abbe",
        title="example")
    # Sets the script with the name "script_1"
    my_script = cloudflare.WorkerScript("myScript",
        account_id="f037e56e89293a057740de681ac9abbe",
        name="script_1",
        content=(lambda path: open(path).read())("script.js"),
        kv_namespace_bindings=[cloudflare.WorkerScriptKvNamespaceBindingArgs(
            name="MY_EXAMPLE_KV_NAMESPACE",
            namespace_id=my_namespace.id,
        )],
        plain_text_bindings=[cloudflare.WorkerScriptPlainTextBindingArgs(
            name="MY_EXAMPLE_PLAIN_TEXT",
            text="foobar",
        )],
        secret_text_bindings=[cloudflare.WorkerScriptSecretTextBindingArgs(
            name="MY_EXAMPLE_SECRET_TEXT",
            text=var["secret_foo_value"],
        )],
        webassembly_bindings=[cloudflare.WorkerScriptWebassemblyBindingArgs(
            name="MY_EXAMPLE_WASM",
            module=(lambda path: base64.b64encode(open(path).read().encode()).decode())("example.wasm"),
        )],
        service_bindings=[cloudflare.WorkerScriptServiceBindingArgs(
            name="MY_SERVICE_BINDING",
            service="MY_SERVICE",
            environment="production",
        )],
        r2_bucket_bindings=[cloudflare.WorkerScriptR2BucketBindingArgs(
            name="MY_BUCKET",
            bucket_name="MY_BUCKET_NAME",
        )],
        analytics_engine_bindings=[cloudflare.WorkerScriptAnalyticsEngineBindingArgs(
            name="MY_DATASET",
            dataset="dataset1",
        )])
    

    Example coming soon!

    Create WorkerScript Resource

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

    Constructor syntax

    new WorkerScript(name: string, args: WorkerScriptArgs, opts?: CustomResourceOptions);
    @overload
    def WorkerScript(resource_name: str,
                     args: WorkerScriptArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def WorkerScript(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     content: Optional[str] = None,
                     name: Optional[str] = None,
                     account_id: Optional[str] = None,
                     analytics_engine_bindings: Optional[Sequence[WorkerScriptAnalyticsEngineBindingArgs]] = None,
                     kv_namespace_bindings: Optional[Sequence[WorkerScriptKvNamespaceBindingArgs]] = None,
                     module: Optional[bool] = None,
                     plain_text_bindings: Optional[Sequence[WorkerScriptPlainTextBindingArgs]] = None,
                     queue_bindings: Optional[Sequence[WorkerScriptQueueBindingArgs]] = None,
                     r2_bucket_bindings: Optional[Sequence[WorkerScriptR2BucketBindingArgs]] = None,
                     secret_text_bindings: Optional[Sequence[WorkerScriptSecretTextBindingArgs]] = None,
                     service_bindings: Optional[Sequence[WorkerScriptServiceBindingArgs]] = None,
                     webassembly_bindings: Optional[Sequence[WorkerScriptWebassemblyBindingArgs]] = None)
    func NewWorkerScript(ctx *Context, name string, args WorkerScriptArgs, opts ...ResourceOption) (*WorkerScript, error)
    public WorkerScript(string name, WorkerScriptArgs args, CustomResourceOptions? opts = null)
    public WorkerScript(String name, WorkerScriptArgs args)
    public WorkerScript(String name, WorkerScriptArgs args, CustomResourceOptions options)
    
    type: cloudflare:WorkerScript
    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 WorkerScriptArgs
    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 WorkerScriptArgs
    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 WorkerScriptArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args WorkerScriptArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args WorkerScriptArgs
    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 workerScriptResource = new Cloudflare.WorkerScript("workerScriptResource", new()
    {
        Content = "string",
        Name = "string",
        AccountId = "string",
        AnalyticsEngineBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptAnalyticsEngineBindingArgs
            {
                Dataset = "string",
                Name = "string",
            },
        },
        KvNamespaceBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptKvNamespaceBindingArgs
            {
                Name = "string",
                NamespaceId = "string",
            },
        },
        Module = false,
        PlainTextBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptPlainTextBindingArgs
            {
                Name = "string",
                Text = "string",
            },
        },
        QueueBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptQueueBindingArgs
            {
                Binding = "string",
                Queue = "string",
            },
        },
        R2BucketBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptR2BucketBindingArgs
            {
                BucketName = "string",
                Name = "string",
            },
        },
        SecretTextBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptSecretTextBindingArgs
            {
                Name = "string",
                Text = "string",
            },
        },
        ServiceBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptServiceBindingArgs
            {
                Name = "string",
                Service = "string",
                Environment = "string",
            },
        },
        WebassemblyBindings = new[]
        {
            new Cloudflare.Inputs.WorkerScriptWebassemblyBindingArgs
            {
                Module = "string",
                Name = "string",
            },
        },
    });
    
    example, err := cloudflare.NewWorkerScript(ctx, "workerScriptResource", &cloudflare.WorkerScriptArgs{
    	Content:   pulumi.String("string"),
    	Name:      pulumi.String("string"),
    	AccountId: pulumi.String("string"),
    	AnalyticsEngineBindings: cloudflare.WorkerScriptAnalyticsEngineBindingArray{
    		&cloudflare.WorkerScriptAnalyticsEngineBindingArgs{
    			Dataset: pulumi.String("string"),
    			Name:    pulumi.String("string"),
    		},
    	},
    	KvNamespaceBindings: cloudflare.WorkerScriptKvNamespaceBindingArray{
    		&cloudflare.WorkerScriptKvNamespaceBindingArgs{
    			Name:        pulumi.String("string"),
    			NamespaceId: pulumi.String("string"),
    		},
    	},
    	Module: pulumi.Bool(false),
    	PlainTextBindings: cloudflare.WorkerScriptPlainTextBindingArray{
    		&cloudflare.WorkerScriptPlainTextBindingArgs{
    			Name: pulumi.String("string"),
    			Text: pulumi.String("string"),
    		},
    	},
    	QueueBindings: cloudflare.WorkerScriptQueueBindingArray{
    		&cloudflare.WorkerScriptQueueBindingArgs{
    			Binding: pulumi.String("string"),
    			Queue:   pulumi.String("string"),
    		},
    	},
    	R2BucketBindings: cloudflare.WorkerScriptR2BucketBindingArray{
    		&cloudflare.WorkerScriptR2BucketBindingArgs{
    			BucketName: pulumi.String("string"),
    			Name:       pulumi.String("string"),
    		},
    	},
    	SecretTextBindings: cloudflare.WorkerScriptSecretTextBindingArray{
    		&cloudflare.WorkerScriptSecretTextBindingArgs{
    			Name: pulumi.String("string"),
    			Text: pulumi.String("string"),
    		},
    	},
    	ServiceBindings: cloudflare.WorkerScriptServiceBindingArray{
    		&cloudflare.WorkerScriptServiceBindingArgs{
    			Name:        pulumi.String("string"),
    			Service:     pulumi.String("string"),
    			Environment: pulumi.String("string"),
    		},
    	},
    	WebassemblyBindings: cloudflare.WorkerScriptWebassemblyBindingArray{
    		&cloudflare.WorkerScriptWebassemblyBindingArgs{
    			Module: pulumi.String("string"),
    			Name:   pulumi.String("string"),
    		},
    	},
    })
    
    var workerScriptResource = new WorkerScript("workerScriptResource", WorkerScriptArgs.builder()
        .content("string")
        .name("string")
        .accountId("string")
        .analyticsEngineBindings(WorkerScriptAnalyticsEngineBindingArgs.builder()
            .dataset("string")
            .name("string")
            .build())
        .kvNamespaceBindings(WorkerScriptKvNamespaceBindingArgs.builder()
            .name("string")
            .namespaceId("string")
            .build())
        .module(false)
        .plainTextBindings(WorkerScriptPlainTextBindingArgs.builder()
            .name("string")
            .text("string")
            .build())
        .queueBindings(WorkerScriptQueueBindingArgs.builder()
            .binding("string")
            .queue("string")
            .build())
        .r2BucketBindings(WorkerScriptR2BucketBindingArgs.builder()
            .bucketName("string")
            .name("string")
            .build())
        .secretTextBindings(WorkerScriptSecretTextBindingArgs.builder()
            .name("string")
            .text("string")
            .build())
        .serviceBindings(WorkerScriptServiceBindingArgs.builder()
            .name("string")
            .service("string")
            .environment("string")
            .build())
        .webassemblyBindings(WorkerScriptWebassemblyBindingArgs.builder()
            .module("string")
            .name("string")
            .build())
        .build());
    
    worker_script_resource = cloudflare.WorkerScript("workerScriptResource",
        content="string",
        name="string",
        account_id="string",
        analytics_engine_bindings=[{
            "dataset": "string",
            "name": "string",
        }],
        kv_namespace_bindings=[{
            "name": "string",
            "namespace_id": "string",
        }],
        module=False,
        plain_text_bindings=[{
            "name": "string",
            "text": "string",
        }],
        queue_bindings=[{
            "binding": "string",
            "queue": "string",
        }],
        r2_bucket_bindings=[{
            "bucket_name": "string",
            "name": "string",
        }],
        secret_text_bindings=[{
            "name": "string",
            "text": "string",
        }],
        service_bindings=[{
            "name": "string",
            "service": "string",
            "environment": "string",
        }],
        webassembly_bindings=[{
            "module": "string",
            "name": "string",
        }])
    
    const workerScriptResource = new cloudflare.WorkerScript("workerScriptResource", {
        content: "string",
        name: "string",
        accountId: "string",
        analyticsEngineBindings: [{
            dataset: "string",
            name: "string",
        }],
        kvNamespaceBindings: [{
            name: "string",
            namespaceId: "string",
        }],
        module: false,
        plainTextBindings: [{
            name: "string",
            text: "string",
        }],
        queueBindings: [{
            binding: "string",
            queue: "string",
        }],
        r2BucketBindings: [{
            bucketName: "string",
            name: "string",
        }],
        secretTextBindings: [{
            name: "string",
            text: "string",
        }],
        serviceBindings: [{
            name: "string",
            service: "string",
            environment: "string",
        }],
        webassemblyBindings: [{
            module: "string",
            name: "string",
        }],
    });
    
    type: cloudflare:WorkerScript
    properties:
        accountId: string
        analyticsEngineBindings:
            - dataset: string
              name: string
        content: string
        kvNamespaceBindings:
            - name: string
              namespaceId: string
        module: false
        name: string
        plainTextBindings:
            - name: string
              text: string
        queueBindings:
            - binding: string
              queue: string
        r2BucketBindings:
            - bucketName: string
              name: string
        secretTextBindings:
            - name: string
              text: string
        serviceBindings:
            - environment: string
              name: string
              service: string
        webassemblyBindings:
            - module: string
              name: string
    

    WorkerScript Resource Properties

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

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The WorkerScript resource accepts the following input properties:

    content String
    The script content.
    name String
    The name for the script. Modifying this attribute will force creation of a new resource.
    accountId String
    The account identifier to target for the resource.
    analyticsEngineBindings List<Property Map>
    kvNamespaceBindings List<Property Map>
    module Boolean
    Whether to upload Worker as a module.
    plainTextBindings List<Property Map>
    queueBindings List<Property Map>
    r2BucketBindings List<Property Map>
    secretTextBindings List<Property Map>
    serviceBindings List<Property Map>
    webassemblyBindings List<Property Map>

    Outputs

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

    Get an existing WorkerScript 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?: WorkerScriptState, opts?: CustomResourceOptions): WorkerScript
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            analytics_engine_bindings: Optional[Sequence[WorkerScriptAnalyticsEngineBindingArgs]] = None,
            content: Optional[str] = None,
            kv_namespace_bindings: Optional[Sequence[WorkerScriptKvNamespaceBindingArgs]] = None,
            module: Optional[bool] = None,
            name: Optional[str] = None,
            plain_text_bindings: Optional[Sequence[WorkerScriptPlainTextBindingArgs]] = None,
            queue_bindings: Optional[Sequence[WorkerScriptQueueBindingArgs]] = None,
            r2_bucket_bindings: Optional[Sequence[WorkerScriptR2BucketBindingArgs]] = None,
            secret_text_bindings: Optional[Sequence[WorkerScriptSecretTextBindingArgs]] = None,
            service_bindings: Optional[Sequence[WorkerScriptServiceBindingArgs]] = None,
            webassembly_bindings: Optional[Sequence[WorkerScriptWebassemblyBindingArgs]] = None) -> WorkerScript
    func GetWorkerScript(ctx *Context, name string, id IDInput, state *WorkerScriptState, opts ...ResourceOption) (*WorkerScript, error)
    public static WorkerScript Get(string name, Input<string> id, WorkerScriptState? state, CustomResourceOptions? opts = null)
    public static WorkerScript get(String name, Output<String> id, WorkerScriptState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:WorkerScript    get:      id: ${id}
    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:
    accountId String
    The account identifier to target for the resource.
    analyticsEngineBindings List<Property Map>
    content String
    The script content.
    kvNamespaceBindings List<Property Map>
    module Boolean
    Whether to upload Worker as a module.
    name String
    The name for the script. Modifying this attribute will force creation of a new resource.
    plainTextBindings List<Property Map>
    queueBindings List<Property Map>
    r2BucketBindings List<Property Map>
    secretTextBindings List<Property Map>
    serviceBindings List<Property Map>
    webassemblyBindings List<Property Map>

    Supporting Types

    WorkerScriptAnalyticsEngineBinding, WorkerScriptAnalyticsEngineBindingArgs

    Dataset string
    The name of the Analytics Engine dataset to write to.
    Name string
    The global variable for the binding in your Worker code.
    Dataset string
    The name of the Analytics Engine dataset to write to.
    Name string
    The global variable for the binding in your Worker code.
    dataset String
    The name of the Analytics Engine dataset to write to.
    name String
    The global variable for the binding in your Worker code.
    dataset string
    The name of the Analytics Engine dataset to write to.
    name string
    The global variable for the binding in your Worker code.
    dataset str
    The name of the Analytics Engine dataset to write to.
    name str
    The global variable for the binding in your Worker code.
    dataset String
    The name of the Analytics Engine dataset to write to.
    name String
    The global variable for the binding in your Worker code.

    WorkerScriptKvNamespaceBinding, WorkerScriptKvNamespaceBindingArgs

    Name string
    The global variable for the binding in your Worker code.
    NamespaceId string
    ID of the KV namespace you want to use.
    Name string
    The global variable for the binding in your Worker code.
    NamespaceId string
    ID of the KV namespace you want to use.
    name String
    The global variable for the binding in your Worker code.
    namespaceId String
    ID of the KV namespace you want to use.
    name string
    The global variable for the binding in your Worker code.
    namespaceId string
    ID of the KV namespace you want to use.
    name str
    The global variable for the binding in your Worker code.
    namespace_id str
    ID of the KV namespace you want to use.
    name String
    The global variable for the binding in your Worker code.
    namespaceId String
    ID of the KV namespace you want to use.

    WorkerScriptPlainTextBinding, WorkerScriptPlainTextBindingArgs

    Name string
    The global variable for the binding in your Worker code.
    Text string
    The plain text you want to store.
    Name string
    The global variable for the binding in your Worker code.
    Text string
    The plain text you want to store.
    name String
    The global variable for the binding in your Worker code.
    text String
    The plain text you want to store.
    name string
    The global variable for the binding in your Worker code.
    text string
    The plain text you want to store.
    name str
    The global variable for the binding in your Worker code.
    text str
    The plain text you want to store.
    name String
    The global variable for the binding in your Worker code.
    text String
    The plain text you want to store.

    WorkerScriptQueueBinding, WorkerScriptQueueBindingArgs

    Binding string
    The name of the global variable for the binding in your Worker code.
    Queue string
    Name of the queue you want to use.
    Binding string
    The name of the global variable for the binding in your Worker code.
    Queue string
    Name of the queue you want to use.
    binding String
    The name of the global variable for the binding in your Worker code.
    queue String
    Name of the queue you want to use.
    binding string
    The name of the global variable for the binding in your Worker code.
    queue string
    Name of the queue you want to use.
    binding str
    The name of the global variable for the binding in your Worker code.
    queue str
    Name of the queue you want to use.
    binding String
    The name of the global variable for the binding in your Worker code.
    queue String
    Name of the queue you want to use.

    WorkerScriptR2BucketBinding, WorkerScriptR2BucketBindingArgs

    BucketName string
    The name of the Bucket to bind to.
    Name string
    The global variable for the binding in your Worker code.
    BucketName string
    The name of the Bucket to bind to.
    Name string
    The global variable for the binding in your Worker code.
    bucketName String
    The name of the Bucket to bind to.
    name String
    The global variable for the binding in your Worker code.
    bucketName string
    The name of the Bucket to bind to.
    name string
    The global variable for the binding in your Worker code.
    bucket_name str
    The name of the Bucket to bind to.
    name str
    The global variable for the binding in your Worker code.
    bucketName String
    The name of the Bucket to bind to.
    name String
    The global variable for the binding in your Worker code.

    WorkerScriptSecretTextBinding, WorkerScriptSecretTextBindingArgs

    Name string
    The global variable for the binding in your Worker code.
    Text string
    The secret text you want to store.
    Name string
    The global variable for the binding in your Worker code.
    Text string
    The secret text you want to store.
    name String
    The global variable for the binding in your Worker code.
    text String
    The secret text you want to store.
    name string
    The global variable for the binding in your Worker code.
    text string
    The secret text you want to store.
    name str
    The global variable for the binding in your Worker code.
    text str
    The secret text you want to store.
    name String
    The global variable for the binding in your Worker code.
    text String
    The secret text you want to store.

    WorkerScriptServiceBinding, WorkerScriptServiceBindingArgs

    Name string
    The global variable for the binding in your Worker code.
    Service string
    The name of the Worker to bind to.
    Environment string
    The name of the Worker environment to bind to.
    Name string
    The global variable for the binding in your Worker code.
    Service string
    The name of the Worker to bind to.
    Environment string
    The name of the Worker environment to bind to.
    name String
    The global variable for the binding in your Worker code.
    service String
    The name of the Worker to bind to.
    environment String
    The name of the Worker environment to bind to.
    name string
    The global variable for the binding in your Worker code.
    service string
    The name of the Worker to bind to.
    environment string
    The name of the Worker environment to bind to.
    name str
    The global variable for the binding in your Worker code.
    service str
    The name of the Worker to bind to.
    environment str
    The name of the Worker environment to bind to.
    name String
    The global variable for the binding in your Worker code.
    service String
    The name of the Worker to bind to.
    environment String
    The name of the Worker environment to bind to.

    WorkerScriptWebassemblyBinding, WorkerScriptWebassemblyBindingArgs

    Module string
    The base64 encoded wasm module you want to store.
    Name string
    The global variable for the binding in your Worker code.
    Module string
    The base64 encoded wasm module you want to store.
    Name string
    The global variable for the binding in your Worker code.
    module String
    The base64 encoded wasm module you want to store.
    name String
    The global variable for the binding in your Worker code.
    module string
    The base64 encoded wasm module you want to store.
    name string
    The global variable for the binding in your Worker code.
    module str
    The base64 encoded wasm module you want to store.
    name str
    The global variable for the binding in your Worker code.
    module String
    The base64 encoded wasm module you want to store.
    name String
    The global variable for the binding in your Worker code.

    Import

     $ pulumi import cloudflare:index/workerScript:WorkerScript example <account_id>/<script_name>
    

    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
    Viewing docs for Cloudflare v4.16.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.