cloudflare.WorkerScript
Explore with Pulumi AI
Provides a Cloudflare worker script resource. In order for a script to be active, you’ll also need to setup a cloudflare.WorkerRoute
.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
import * as std from "@pulumi/std";
const myNamespace = new cloudflare.WorkersKvNamespace("my_namespace", {
accountId: "f037e56e89293a057740de681ac9abbe",
title: "example",
});
// Sets the script with the name "script_1"
const myScript = new cloudflare.WorkerScript("my_script", {
accountId: "f037e56e89293a057740de681ac9abbe",
name: "script_1",
content: std.file({
input: "script.js",
}).then(invoke => invoke.result),
kvNamespaceBindings: [{
name: "MY_EXAMPLE_KV_NAMESPACE",
namespaceId: myNamespace.id,
}],
plainTextBindings: [{
name: "MY_EXAMPLE_PLAIN_TEXT",
text: "foobar",
}],
secretTextBindings: [{
name: "MY_EXAMPLE_SECRET_TEXT",
text: secretFooValue,
}],
webassemblyBindings: [{
name: "MY_EXAMPLE_WASM",
module: std.filebase64({
input: "example.wasm",
}).then(invoke => invoke.result),
}],
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 pulumi_cloudflare as cloudflare
import pulumi_std as std
my_namespace = cloudflare.WorkersKvNamespace("my_namespace",
account_id="f037e56e89293a057740de681ac9abbe",
title="example")
# Sets the script with the name "script_1"
my_script = cloudflare.WorkerScript("my_script",
account_id="f037e56e89293a057740de681ac9abbe",
name="script_1",
content=std.file(input="script.js").result,
kv_namespace_bindings=[{
"name": "MY_EXAMPLE_KV_NAMESPACE",
"namespace_id": my_namespace.id,
}],
plain_text_bindings=[{
"name": "MY_EXAMPLE_PLAIN_TEXT",
"text": "foobar",
}],
secret_text_bindings=[{
"name": "MY_EXAMPLE_SECRET_TEXT",
"text": secret_foo_value,
}],
webassembly_bindings=[{
"name": "MY_EXAMPLE_WASM",
"module": std.filebase64(input="example.wasm").result,
}],
service_bindings=[{
"name": "MY_SERVICE_BINDING",
"service": "MY_SERVICE",
"environment": "production",
}],
r2_bucket_bindings=[{
"name": "MY_BUCKET",
"bucket_name": "MY_BUCKET_NAME",
}],
analytics_engine_bindings=[{
"name": "MY_DATASET",
"dataset": "dataset1",
}])
package main
import (
"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
"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 {
myNamespace, err := cloudflare.NewWorkersKvNamespace(ctx, "my_namespace", &cloudflare.WorkersKvNamespaceArgs{
AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
Title: pulumi.String("example"),
})
if err != nil {
return err
}
invokeFile, err := std.File(ctx, &std.FileArgs{
Input: "script.js",
}, nil)
if err != nil {
return err
}
invokeFilebase641, err := std.Filebase64(ctx, &std.Filebase64Args{
Input: "example.wasm",
}, nil)
if err != nil {
return err
}
// Sets the script with the name "script_1"
_, err = cloudflare.NewWorkerScript(ctx, "my_script", &cloudflare.WorkerScriptArgs{
AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
Name: pulumi.String("script_1"),
Content: pulumi.String(invokeFile.Result),
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(secretFooValue),
},
},
WebassemblyBindings: cloudflare.WorkerScriptWebassemblyBindingArray{
&cloudflare.WorkerScriptWebassemblyBindingArgs{
Name: pulumi.String("MY_EXAMPLE_WASM"),
Module: pulumi.String(invokeFilebase641.Result),
},
},
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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var myNamespace = new Cloudflare.WorkersKvNamespace("my_namespace", new()
{
AccountId = "f037e56e89293a057740de681ac9abbe",
Title = "example",
});
// Sets the script with the name "script_1"
var myScript = new Cloudflare.WorkerScript("my_script", new()
{
AccountId = "f037e56e89293a057740de681ac9abbe",
Name = "script_1",
Content = Std.File.Invoke(new()
{
Input = "script.js",
}).Apply(invoke => invoke.Result),
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 = secretFooValue,
},
},
WebassemblyBindings = new[]
{
new Cloudflare.Inputs.WorkerScriptWebassemblyBindingArgs
{
Name = "MY_EXAMPLE_WASM",
Module = Std.Filebase64.Invoke(new()
{
Input = "example.wasm",
}).Apply(invoke => invoke.Result),
},
},
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 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());
// Sets the script with the name "script_1"
var myScript = new WorkerScript("myScript", WorkerScriptArgs.builder()
.accountId("f037e56e89293a057740de681ac9abbe")
.name("script_1")
.content(StdFunctions.file(FileArgs.builder()
.input("script.js")
.build()).result())
.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(secretFooValue)
.build())
.webassemblyBindings(WorkerScriptWebassemblyBindingArgs.builder()
.name("MY_EXAMPLE_WASM")
.module(StdFunctions.filebase64(Filebase64Args.builder()
.input("example.wasm")
.build()).result())
.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());
}
}
resources:
myNamespace:
type: cloudflare:WorkersKvNamespace
name: my_namespace
properties:
accountId: f037e56e89293a057740de681ac9abbe
title: example
# Sets the script with the name "script_1"
myScript:
type: cloudflare:WorkerScript
name: my_script
properties:
accountId: f037e56e89293a057740de681ac9abbe
name: script_1
content:
fn::invoke:
Function: std:file
Arguments:
input: script.js
Return: result
kvNamespaceBindings:
- name: MY_EXAMPLE_KV_NAMESPACE
namespaceId: ${myNamespace.id}
plainTextBindings:
- name: MY_EXAMPLE_PLAIN_TEXT
text: foobar
secretTextBindings:
- name: MY_EXAMPLE_SECRET_TEXT
text: ${secretFooValue}
webassemblyBindings:
- name: MY_EXAMPLE_WASM
module:
fn::invoke:
Function: std:filebase64
Arguments:
input: example.wasm
Return: result
serviceBindings:
- name: MY_SERVICE_BINDING
service: MY_SERVICE
environment: production
r2BucketBindings:
- name: MY_BUCKET
bucketName: MY_BUCKET_NAME
analyticsEngineBindings:
- name: MY_DATASET
dataset: dataset1
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,
module: Optional[bool] = None,
placements: Optional[Sequence[WorkerScriptPlacementArgs]] = None,
d1_database_bindings: Optional[Sequence[WorkerScriptD1DatabaseBindingArgs]] = None,
dispatch_namespace: Optional[str] = None,
hyperdrive_config_bindings: Optional[Sequence[WorkerScriptHyperdriveConfigBindingArgs]] = None,
kv_namespace_bindings: Optional[Sequence[WorkerScriptKvNamespaceBindingArgs]] = None,
logpush: Optional[bool] = None,
compatibility_date: Optional[str] = None,
analytics_engine_bindings: Optional[Sequence[WorkerScriptAnalyticsEngineBindingArgs]] = None,
compatibility_flags: Optional[Sequence[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,
tags: Optional[Sequence[str]] = 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",
Module = false,
Placements = new[]
{
new Cloudflare.Inputs.WorkerScriptPlacementArgs
{
Mode = "string",
},
},
D1DatabaseBindings = new[]
{
new Cloudflare.Inputs.WorkerScriptD1DatabaseBindingArgs
{
DatabaseId = "string",
Name = "string",
},
},
DispatchNamespace = "string",
HyperdriveConfigBindings = new[]
{
new Cloudflare.Inputs.WorkerScriptHyperdriveConfigBindingArgs
{
Binding = "string",
Id = "string",
},
},
KvNamespaceBindings = new[]
{
new Cloudflare.Inputs.WorkerScriptKvNamespaceBindingArgs
{
Name = "string",
NamespaceId = "string",
},
},
Logpush = false,
CompatibilityDate = "string",
AnalyticsEngineBindings = new[]
{
new Cloudflare.Inputs.WorkerScriptAnalyticsEngineBindingArgs
{
Dataset = "string",
Name = "string",
},
},
CompatibilityFlags = new[]
{
"string",
},
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",
},
},
Tags = new[]
{
"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"),
Module: pulumi.Bool(false),
Placements: cloudflare.WorkerScriptPlacementArray{
&cloudflare.WorkerScriptPlacementArgs{
Mode: pulumi.String("string"),
},
},
D1DatabaseBindings: cloudflare.WorkerScriptD1DatabaseBindingArray{
&cloudflare.WorkerScriptD1DatabaseBindingArgs{
DatabaseId: pulumi.String("string"),
Name: pulumi.String("string"),
},
},
DispatchNamespace: pulumi.String("string"),
HyperdriveConfigBindings: cloudflare.WorkerScriptHyperdriveConfigBindingArray{
&cloudflare.WorkerScriptHyperdriveConfigBindingArgs{
Binding: pulumi.String("string"),
Id: pulumi.String("string"),
},
},
KvNamespaceBindings: cloudflare.WorkerScriptKvNamespaceBindingArray{
&cloudflare.WorkerScriptKvNamespaceBindingArgs{
Name: pulumi.String("string"),
NamespaceId: pulumi.String("string"),
},
},
Logpush: pulumi.Bool(false),
CompatibilityDate: pulumi.String("string"),
AnalyticsEngineBindings: cloudflare.WorkerScriptAnalyticsEngineBindingArray{
&cloudflare.WorkerScriptAnalyticsEngineBindingArgs{
Dataset: pulumi.String("string"),
Name: pulumi.String("string"),
},
},
CompatibilityFlags: pulumi.StringArray{
pulumi.String("string"),
},
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"),
},
},
Tags: pulumi.StringArray{
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")
.module(false)
.placements(WorkerScriptPlacementArgs.builder()
.mode("string")
.build())
.d1DatabaseBindings(WorkerScriptD1DatabaseBindingArgs.builder()
.databaseId("string")
.name("string")
.build())
.dispatchNamespace("string")
.hyperdriveConfigBindings(WorkerScriptHyperdriveConfigBindingArgs.builder()
.binding("string")
.id("string")
.build())
.kvNamespaceBindings(WorkerScriptKvNamespaceBindingArgs.builder()
.name("string")
.namespaceId("string")
.build())
.logpush(false)
.compatibilityDate("string")
.analyticsEngineBindings(WorkerScriptAnalyticsEngineBindingArgs.builder()
.dataset("string")
.name("string")
.build())
.compatibilityFlags("string")
.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())
.tags("string")
.webassemblyBindings(WorkerScriptWebassemblyBindingArgs.builder()
.module("string")
.name("string")
.build())
.build());
worker_script_resource = cloudflare.WorkerScript("workerScriptResource",
content="string",
name="string",
account_id="string",
module=False,
placements=[{
"mode": "string",
}],
d1_database_bindings=[{
"database_id": "string",
"name": "string",
}],
dispatch_namespace="string",
hyperdrive_config_bindings=[{
"binding": "string",
"id": "string",
}],
kv_namespace_bindings=[{
"name": "string",
"namespace_id": "string",
}],
logpush=False,
compatibility_date="string",
analytics_engine_bindings=[{
"dataset": "string",
"name": "string",
}],
compatibility_flags=["string"],
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",
}],
tags=["string"],
webassembly_bindings=[{
"module": "string",
"name": "string",
}])
const workerScriptResource = new cloudflare.WorkerScript("workerScriptResource", {
content: "string",
name: "string",
accountId: "string",
module: false,
placements: [{
mode: "string",
}],
d1DatabaseBindings: [{
databaseId: "string",
name: "string",
}],
dispatchNamespace: "string",
hyperdriveConfigBindings: [{
binding: "string",
id: "string",
}],
kvNamespaceBindings: [{
name: "string",
namespaceId: "string",
}],
logpush: false,
compatibilityDate: "string",
analyticsEngineBindings: [{
dataset: "string",
name: "string",
}],
compatibilityFlags: ["string"],
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",
}],
tags: ["string"],
webassemblyBindings: [{
module: "string",
name: "string",
}],
});
type: cloudflare:WorkerScript
properties:
accountId: string
analyticsEngineBindings:
- dataset: string
name: string
compatibilityDate: string
compatibilityFlags:
- string
content: string
d1DatabaseBindings:
- databaseId: string
name: string
dispatchNamespace: string
hyperdriveConfigBindings:
- binding: string
id: string
kvNamespaceBindings:
- name: string
namespaceId: string
logpush: false
module: false
name: string
placements:
- mode: 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
tags:
- 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:
- Account
Id string - The account identifier to target for the resource.
- Content string
- The script content.
- Name string
- The name for the script. Modifying this attribute will force creation of a new resource.
- Analytics
Engine List<WorkerBindings Script Analytics Engine Binding> - Compatibility
Date string - The date to use for the compatibility flag.
- Compatibility
Flags List<string> - Compatibility flags used for Worker Scripts.
- D1Database
Bindings List<WorkerScript D1Database Binding> - Dispatch
Namespace string - Name of the Workers for Platforms dispatch namespace.
- Hyperdrive
Config List<WorkerBindings Script Hyperdrive Config Binding> - Kv
Namespace List<WorkerBindings Script Kv Namespace Binding> - Logpush bool
- Enabling allows Worker events to be sent to a defined Logpush destination.
- Module bool
- Whether to upload Worker as a module.
- Placements
List<Worker
Script Placement> - Plain
Text List<WorkerBindings Script Plain Text Binding> - Queue
Bindings List<WorkerScript Queue Binding> - R2Bucket
Bindings List<WorkerScript R2Bucket Binding> - Secret
Text List<WorkerBindings Script Secret Text Binding> - Service
Bindings List<WorkerScript Service Binding> - List<string>
- Webassembly
Bindings List<WorkerScript Webassembly Binding>
- Account
Id string - The account identifier to target for the resource.
- Content string
- The script content.
- Name string
- The name for the script. Modifying this attribute will force creation of a new resource.
- Analytics
Engine []WorkerBindings Script Analytics Engine Binding Args - Compatibility
Date string - The date to use for the compatibility flag.
- Compatibility
Flags []string - Compatibility flags used for Worker Scripts.
- D1Database
Bindings []WorkerScript D1Database Binding Args - Dispatch
Namespace string - Name of the Workers for Platforms dispatch namespace.
- Hyperdrive
Config []WorkerBindings Script Hyperdrive Config Binding Args - Kv
Namespace []WorkerBindings Script Kv Namespace Binding Args - Logpush bool
- Enabling allows Worker events to be sent to a defined Logpush destination.
- Module bool
- Whether to upload Worker as a module.
- Placements
[]Worker
Script Placement Args - Plain
Text []WorkerBindings Script Plain Text Binding Args - Queue
Bindings []WorkerScript Queue Binding Args - R2Bucket
Bindings []WorkerScript R2Bucket Binding Args - Secret
Text []WorkerBindings Script Secret Text Binding Args - Service
Bindings []WorkerScript Service Binding Args - []string
- Webassembly
Bindings []WorkerScript Webassembly Binding Args
- account
Id String - The account identifier to target for the resource.
- content String
- The script content.
- name String
- The name for the script. Modifying this attribute will force creation of a new resource.
- analytics
Engine List<WorkerBindings Script Analytics Engine Binding> - compatibility
Date String - The date to use for the compatibility flag.
- compatibility
Flags List<String> - Compatibility flags used for Worker Scripts.
- d1Database
Bindings List<WorkerScript D1Database Binding> - dispatch
Namespace String - Name of the Workers for Platforms dispatch namespace.
- hyperdrive
Config List<WorkerBindings Script Hyperdrive Config Binding> - kv
Namespace List<WorkerBindings Script Kv Namespace Binding> - logpush Boolean
- Enabling allows Worker events to be sent to a defined Logpush destination.
- module Boolean
- Whether to upload Worker as a module.
- placements
List<Worker
Script Placement> - plain
Text List<WorkerBindings Script Plain Text Binding> - queue
Bindings List<WorkerScript Queue Binding> - r2Bucket
Bindings List<WorkerScript R2Bucket Binding> - secret
Text List<WorkerBindings Script Secret Text Binding> - service
Bindings List<WorkerScript Service Binding> - List<String>
- webassembly
Bindings List<WorkerScript Webassembly Binding>
- account
Id string - The account identifier to target for the resource.
- content string
- The script content.
- name string
- The name for the script. Modifying this attribute will force creation of a new resource.
- analytics
Engine WorkerBindings Script Analytics Engine Binding[] - compatibility
Date string - The date to use for the compatibility flag.
- compatibility
Flags string[] - Compatibility flags used for Worker Scripts.
- d1Database
Bindings WorkerScript D1Database Binding[] - dispatch
Namespace string - Name of the Workers for Platforms dispatch namespace.
- hyperdrive
Config WorkerBindings Script Hyperdrive Config Binding[] - kv
Namespace WorkerBindings Script Kv Namespace Binding[] - logpush boolean
- Enabling allows Worker events to be sent to a defined Logpush destination.
- module boolean
- Whether to upload Worker as a module.
- placements
Worker
Script Placement[] - plain
Text WorkerBindings Script Plain Text Binding[] - queue
Bindings WorkerScript Queue Binding[] - r2Bucket
Bindings WorkerScript R2Bucket Binding[] - secret
Text WorkerBindings Script Secret Text Binding[] - service
Bindings WorkerScript Service Binding[] - string[]
- webassembly
Bindings WorkerScript Webassembly Binding[]
- account_
id str - The account identifier to target for the resource.
- content str
- The script content.
- name str
- The name for the script. Modifying this attribute will force creation of a new resource.
- analytics_
engine_ Sequence[Workerbindings Script Analytics Engine Binding Args] - compatibility_
date str - The date to use for the compatibility flag.
- compatibility_
flags Sequence[str] - Compatibility flags used for Worker Scripts.
- d1_
database_ Sequence[Workerbindings Script D1Database Binding Args] - dispatch_
namespace str - Name of the Workers for Platforms dispatch namespace.
- hyperdrive_
config_ Sequence[Workerbindings Script Hyperdrive Config Binding Args] - kv_
namespace_ Sequence[Workerbindings Script Kv Namespace Binding Args] - logpush bool
- Enabling allows Worker events to be sent to a defined Logpush destination.
- module bool
- Whether to upload Worker as a module.
- placements
Sequence[Worker
Script Placement Args] - plain_
text_ Sequence[Workerbindings Script Plain Text Binding Args] - queue_
bindings Sequence[WorkerScript Queue Binding Args] - r2_
bucket_ Sequence[Workerbindings Script R2Bucket Binding Args] - secret_
text_ Sequence[Workerbindings Script Secret Text Binding Args] - service_
bindings Sequence[WorkerScript Service Binding Args] - Sequence[str]
- webassembly_
bindings Sequence[WorkerScript Webassembly Binding Args]
- account
Id String - The account identifier to target for the resource.
- content String
- The script content.
- name String
- The name for the script. Modifying this attribute will force creation of a new resource.
- analytics
Engine List<Property Map>Bindings - compatibility
Date String - The date to use for the compatibility flag.
- compatibility
Flags List<String> - Compatibility flags used for Worker Scripts.
- d1Database
Bindings List<Property Map> - dispatch
Namespace String - Name of the Workers for Platforms dispatch namespace.
- hyperdrive
Config List<Property Map>Bindings - kv
Namespace List<Property Map>Bindings - logpush Boolean
- Enabling allows Worker events to be sent to a defined Logpush destination.
- module Boolean
- Whether to upload Worker as a module.
- placements List<Property Map>
- plain
Text List<Property Map>Bindings - queue
Bindings List<Property Map> - r2Bucket
Bindings List<Property Map> - secret
Text List<Property Map>Bindings - service
Bindings List<Property Map> - List<String>
- webassembly
Bindings 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,
compatibility_date: Optional[str] = None,
compatibility_flags: Optional[Sequence[str]] = None,
content: Optional[str] = None,
d1_database_bindings: Optional[Sequence[WorkerScriptD1DatabaseBindingArgs]] = None,
dispatch_namespace: Optional[str] = None,
hyperdrive_config_bindings: Optional[Sequence[WorkerScriptHyperdriveConfigBindingArgs]] = None,
kv_namespace_bindings: Optional[Sequence[WorkerScriptKvNamespaceBindingArgs]] = None,
logpush: Optional[bool] = None,
module: Optional[bool] = None,
name: Optional[str] = None,
placements: Optional[Sequence[WorkerScriptPlacementArgs]] = 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,
tags: Optional[Sequence[str]] = 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)
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.
- Account
Id string - The account identifier to target for the resource.
- Analytics
Engine List<WorkerBindings Script Analytics Engine Binding> - Compatibility
Date string - The date to use for the compatibility flag.
- Compatibility
Flags List<string> - Compatibility flags used for Worker Scripts.
- Content string
- The script content.
- D1Database
Bindings List<WorkerScript D1Database Binding> - Dispatch
Namespace string - Name of the Workers for Platforms dispatch namespace.
- Hyperdrive
Config List<WorkerBindings Script Hyperdrive Config Binding> - Kv
Namespace List<WorkerBindings Script Kv Namespace Binding> - Logpush bool
- Enabling allows Worker events to be sent to a defined Logpush destination.
- Module bool
- Whether to upload Worker as a module.
- Name string
- The name for the script. Modifying this attribute will force creation of a new resource.
- Placements
List<Worker
Script Placement> - Plain
Text List<WorkerBindings Script Plain Text Binding> - Queue
Bindings List<WorkerScript Queue Binding> - R2Bucket
Bindings List<WorkerScript R2Bucket Binding> - Secret
Text List<WorkerBindings Script Secret Text Binding> - Service
Bindings List<WorkerScript Service Binding> - List<string>
- Webassembly
Bindings List<WorkerScript Webassembly Binding>
- Account
Id string - The account identifier to target for the resource.
- Analytics
Engine []WorkerBindings Script Analytics Engine Binding Args - Compatibility
Date string - The date to use for the compatibility flag.
- Compatibility
Flags []string - Compatibility flags used for Worker Scripts.
- Content string
- The script content.
- D1Database
Bindings []WorkerScript D1Database Binding Args - Dispatch
Namespace string - Name of the Workers for Platforms dispatch namespace.
- Hyperdrive
Config []WorkerBindings Script Hyperdrive Config Binding Args - Kv
Namespace []WorkerBindings Script Kv Namespace Binding Args - Logpush bool
- Enabling allows Worker events to be sent to a defined Logpush destination.
- Module bool
- Whether to upload Worker as a module.
- Name string
- The name for the script. Modifying this attribute will force creation of a new resource.
- Placements
[]Worker
Script Placement Args - Plain
Text []WorkerBindings Script Plain Text Binding Args - Queue
Bindings []WorkerScript Queue Binding Args - R2Bucket
Bindings []WorkerScript R2Bucket Binding Args - Secret
Text []WorkerBindings Script Secret Text Binding Args - Service
Bindings []WorkerScript Service Binding Args - []string
- Webassembly
Bindings []WorkerScript Webassembly Binding Args
- account
Id String - The account identifier to target for the resource.
- analytics
Engine List<WorkerBindings Script Analytics Engine Binding> - compatibility
Date String - The date to use for the compatibility flag.
- compatibility
Flags List<String> - Compatibility flags used for Worker Scripts.
- content String
- The script content.
- d1Database
Bindings List<WorkerScript D1Database Binding> - dispatch
Namespace String - Name of the Workers for Platforms dispatch namespace.
- hyperdrive
Config List<WorkerBindings Script Hyperdrive Config Binding> - kv
Namespace List<WorkerBindings Script Kv Namespace Binding> - logpush Boolean
- Enabling allows Worker events to be sent to a defined Logpush destination.
- 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.
- placements
List<Worker
Script Placement> - plain
Text List<WorkerBindings Script Plain Text Binding> - queue
Bindings List<WorkerScript Queue Binding> - r2Bucket
Bindings List<WorkerScript R2Bucket Binding> - secret
Text List<WorkerBindings Script Secret Text Binding> - service
Bindings List<WorkerScript Service Binding> - List<String>
- webassembly
Bindings List<WorkerScript Webassembly Binding>
- account
Id string - The account identifier to target for the resource.
- analytics
Engine WorkerBindings Script Analytics Engine Binding[] - compatibility
Date string - The date to use for the compatibility flag.
- compatibility
Flags string[] - Compatibility flags used for Worker Scripts.
- content string
- The script content.
- d1Database
Bindings WorkerScript D1Database Binding[] - dispatch
Namespace string - Name of the Workers for Platforms dispatch namespace.
- hyperdrive
Config WorkerBindings Script Hyperdrive Config Binding[] - kv
Namespace WorkerBindings Script Kv Namespace Binding[] - logpush boolean
- Enabling allows Worker events to be sent to a defined Logpush destination.
- 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.
- placements
Worker
Script Placement[] - plain
Text WorkerBindings Script Plain Text Binding[] - queue
Bindings WorkerScript Queue Binding[] - r2Bucket
Bindings WorkerScript R2Bucket Binding[] - secret
Text WorkerBindings Script Secret Text Binding[] - service
Bindings WorkerScript Service Binding[] - string[]
- webassembly
Bindings WorkerScript Webassembly Binding[]
- account_
id str - The account identifier to target for the resource.
- analytics_
engine_ Sequence[Workerbindings Script Analytics Engine Binding Args] - compatibility_
date str - The date to use for the compatibility flag.
- compatibility_
flags Sequence[str] - Compatibility flags used for Worker Scripts.
- content str
- The script content.
- d1_
database_ Sequence[Workerbindings Script D1Database Binding Args] - dispatch_
namespace str - Name of the Workers for Platforms dispatch namespace.
- hyperdrive_
config_ Sequence[Workerbindings Script Hyperdrive Config Binding Args] - kv_
namespace_ Sequence[Workerbindings Script Kv Namespace Binding Args] - logpush bool
- Enabling allows Worker events to be sent to a defined Logpush destination.
- module bool
- Whether to upload Worker as a module.
- name str
- The name for the script. Modifying this attribute will force creation of a new resource.
- placements
Sequence[Worker
Script Placement Args] - plain_
text_ Sequence[Workerbindings Script Plain Text Binding Args] - queue_
bindings Sequence[WorkerScript Queue Binding Args] - r2_
bucket_ Sequence[Workerbindings Script R2Bucket Binding Args] - secret_
text_ Sequence[Workerbindings Script Secret Text Binding Args] - service_
bindings Sequence[WorkerScript Service Binding Args] - Sequence[str]
- webassembly_
bindings Sequence[WorkerScript Webassembly Binding Args]
- account
Id String - The account identifier to target for the resource.
- analytics
Engine List<Property Map>Bindings - compatibility
Date String - The date to use for the compatibility flag.
- compatibility
Flags List<String> - Compatibility flags used for Worker Scripts.
- content String
- The script content.
- d1Database
Bindings List<Property Map> - dispatch
Namespace String - Name of the Workers for Platforms dispatch namespace.
- hyperdrive
Config List<Property Map>Bindings - kv
Namespace List<Property Map>Bindings - logpush Boolean
- Enabling allows Worker events to be sent to a defined Logpush destination.
- 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.
- placements List<Property Map>
- plain
Text List<Property Map>Bindings - queue
Bindings List<Property Map> - r2Bucket
Bindings List<Property Map> - secret
Text List<Property Map>Bindings - service
Bindings List<Property Map> - List<String>
- webassembly
Bindings List<Property Map>
Supporting Types
WorkerScriptAnalyticsEngineBinding, WorkerScriptAnalyticsEngineBindingArgs
WorkerScriptD1DatabaseBinding, WorkerScriptD1DatabaseBindingArgs
- Database
Id string - Database ID of D1 database to use.
- Name string
- The global variable for the binding in your Worker code.
- Database
Id string - Database ID of D1 database to use.
- Name string
- The global variable for the binding in your Worker code.
- database
Id String - Database ID of D1 database to use.
- name String
- The global variable for the binding in your Worker code.
- database
Id string - Database ID of D1 database to use.
- name string
- The global variable for the binding in your Worker code.
- database_
id str - Database ID of D1 database to use.
- name str
- The global variable for the binding in your Worker code.
- database
Id String - Database ID of D1 database to use.
- name String
- The global variable for the binding in your Worker code.
WorkerScriptHyperdriveConfigBinding, WorkerScriptHyperdriveConfigBindingArgs
WorkerScriptKvNamespaceBinding, WorkerScriptKvNamespaceBindingArgs
- Name string
- The global variable for the binding in your Worker code.
- Namespace
Id string - ID of the KV namespace you want to use.
- Name string
- The global variable for the binding in your Worker code.
- Namespace
Id string - ID of the KV namespace you want to use.
- name String
- The global variable for the binding in your Worker code.
- namespace
Id String - ID of the KV namespace you want to use.
- name string
- The global variable for the binding in your Worker code.
- namespace
Id 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.
- namespace
Id String - ID of the KV namespace you want to use.
WorkerScriptPlacement, WorkerScriptPlacementArgs
- Mode string
- The placement mode for the Worker. Available values:
smart
.
- Mode string
- The placement mode for the Worker. Available values:
smart
.
- mode String
- The placement mode for the Worker. Available values:
smart
.
- mode string
- The placement mode for the Worker. Available values:
smart
.
- mode str
- The placement mode for the Worker. Available values:
smart
.
- mode String
- The placement mode for the Worker. Available values:
smart
.
WorkerScriptPlainTextBinding, WorkerScriptPlainTextBindingArgs
WorkerScriptQueueBinding, WorkerScriptQueueBindingArgs
WorkerScriptR2BucketBinding, WorkerScriptR2BucketBindingArgs
- Bucket
Name string - The name of the Bucket to bind to.
- Name string
- The global variable for the binding in your Worker code.
- Bucket
Name string - The name of the Bucket to bind to.
- Name string
- The global variable for the binding in your Worker code.
- bucket
Name String - The name of the Bucket to bind to.
- name String
- The global variable for the binding in your Worker code.
- bucket
Name 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.
- bucket
Name String - The name of the Bucket to bind to.
- name String
- The global variable for the binding in your Worker code.
WorkerScriptSecretTextBinding, WorkerScriptSecretTextBindingArgs
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
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.