Skip to content
Start here

Workers

WorkersBetaWorkers

resource cloudflare_worker

required Expand Collapse
account_id: String

Identifier.

name: String

Name of the Worker.

optional Expand Collapse
logpush?: Bool

Whether logpush is enabled for the Worker.

tags?: Set[String]

Tags associated with the Worker.

observability?: Attributes

Observability settings for the Worker.

enabled?: Bool

Whether observability is enabled for the Worker.

head_sampling_rate?: Float64

The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).

logs?: Attributes

Log settings for the Worker.

destinations?: List[String]

A list of destinations where logs will be exported to.

enabled?: Bool

Whether logs are enabled for the Worker.

head_sampling_rate?: Float64

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).

invocation_logs?: Bool

Whether invocation logs are enabled for the Worker.

persist?: Bool

Whether log persistence is enabled for the Worker.

traces?: Attributes

Trace settings for the Worker.

destinations?: List[String]

A list of destinations where traces will be exported to.

enabled?: Bool

Whether traces are enabled for the Worker.

head_sampling_rate?: Float64

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).

persist?: Bool

Whether trace persistence is enabled for the Worker.

subdomain?: Attributes

Subdomain settings for the Worker.

enabled?: Bool

Whether the *.workers.dev subdomain is enabled for the Worker.

previews_enabled?: Bool

Whether preview URLs are enabled for the Worker.

tail_consumers?: Set[Attributes]

Other Workers that should consume logs from the Worker.

name: String

Name of the consumer Worker.

computed Expand Collapse
id: String

Immutable ID of the Worker.

created_on: Time

When the Worker was created.

deployed_on: Time

When the Worker's most recent deployment was created. null if the Worker has never been deployed.

updated_on: Time

When the Worker was most recently updated.

references: Attributes

Other resources that reference the Worker and depend on it existing.

dispatch_namespace_outbounds: List[Attributes]

Other Workers that reference the Worker as an outbound for a dispatch namespace.

namespace_id: String

ID of the dispatch namespace.

namespace_name: String

Name of the dispatch namespace.

worker_id: String

ID of the Worker using the dispatch namespace.

worker_name: String

Name of the Worker using the dispatch namespace.

domains: List[Attributes]

Custom domains connected to the Worker.

id: String

ID of the custom domain.

certificate_id: String

ID of the TLS certificate issued for the custom domain.

hostname: String

Full hostname of the custom domain, including the zone name.

zone_id: String

ID of the zone.

zone_name: String

Name of the zone.

durable_objects: List[Attributes]

Other Workers that reference Durable Object classes implemented by the Worker.

namespace_id: String

ID of the Durable Object namespace being used.

namespace_name: String

Name of the Durable Object namespace being used.

worker_id: String

ID of the Worker using the Durable Object implementation.

worker_name: String

Name of the Worker using the Durable Object implementation.

queues: List[Attributes]

Queues that send messages to the Worker.

queue_consumer_id: String

ID of the queue consumer configuration.

queue_id: String

ID of the queue.

queue_name: String

Name of the queue.

workers: List[Attributes]

Other Workers that reference the Worker using service bindings.

id: String

ID of the referencing Worker.

name: String

Name of the referencing Worker.

cloudflare_worker

resource "cloudflare_worker" "example_worker" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  name = "my-worker"
  logpush = true
  observability = {
    enabled = true
    head_sampling_rate = 1
    logs = {
      destinations = ["string"]
      enabled = true
      head_sampling_rate = 1
      invocation_logs = true
      persist = true
    }
    traces = {
      destinations = ["string"]
      enabled = true
      head_sampling_rate = 1
      persist = true
    }
  }
  subdomain = {
    enabled = true
    previews_enabled = true
  }
  tags = ["my-team", "my-public-api"]
  tail_consumers = [{
    name = "my-tail-consumer"
  }]
}

data cloudflare_worker

required Expand Collapse
account_id: String

Identifier.

optional Expand Collapse
worker_id?: String

Identifier for the Worker, which can be ID or name.

filter?: Attributes
order?: String

Sort direction.

order_by?: String

Property to sort results by.

computed Expand Collapse
id: String

Identifier for the Worker, which can be ID or name.

created_on: Time

When the Worker was created.

deployed_on: Time

When the Worker's most recent deployment was created. null if the Worker has never been deployed.

logpush: Bool

Whether logpush is enabled for the Worker.

name: String

Name of the Worker.

updated_on: Time

When the Worker was most recently updated.

tags: Set[String]

Tags associated with the Worker.

observability: Attributes

Observability settings for the Worker.

enabled: Bool

Whether observability is enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).

logs: Attributes

Log settings for the Worker.

destinations: List[String]

A list of destinations where logs will be exported to.

enabled: Bool

Whether logs are enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).

invocation_logs: Bool

Whether invocation logs are enabled for the Worker.

persist: Bool

Whether log persistence is enabled for the Worker.

traces: Attributes

Trace settings for the Worker.

destinations: List[String]

A list of destinations where traces will be exported to.

enabled: Bool

Whether traces are enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).

persist: Bool

Whether trace persistence is enabled for the Worker.

references: Attributes

Other resources that reference the Worker and depend on it existing.

dispatch_namespace_outbounds: List[Attributes]

Other Workers that reference the Worker as an outbound for a dispatch namespace.

namespace_id: String

ID of the dispatch namespace.

namespace_name: String

Name of the dispatch namespace.

worker_id: String

ID of the Worker using the dispatch namespace.

worker_name: String

Name of the Worker using the dispatch namespace.

domains: List[Attributes]

Custom domains connected to the Worker.

id: String

ID of the custom domain.

certificate_id: String

ID of the TLS certificate issued for the custom domain.

hostname: String

Full hostname of the custom domain, including the zone name.

zone_id: String

ID of the zone.

zone_name: String

Name of the zone.

durable_objects: List[Attributes]

Other Workers that reference Durable Object classes implemented by the Worker.

namespace_id: String

ID of the Durable Object namespace being used.

namespace_name: String

Name of the Durable Object namespace being used.

worker_id: String

ID of the Worker using the Durable Object implementation.

worker_name: String

Name of the Worker using the Durable Object implementation.

queues: List[Attributes]

Queues that send messages to the Worker.

queue_consumer_id: String

ID of the queue consumer configuration.

queue_id: String

ID of the queue.

queue_name: String

Name of the queue.

workers: List[Attributes]

Other Workers that reference the Worker using service bindings.

id: String

ID of the referencing Worker.

name: String

Name of the referencing Worker.

subdomain: Attributes

Subdomain settings for the Worker.

enabled: Bool

Whether the *.workers.dev subdomain is enabled for the Worker.

previews_enabled: Bool

Whether preview URLs are enabled for the Worker.

tail_consumers: Set[Attributes]

Other Workers that should consume logs from the Worker.

name: String

Name of the consumer Worker.

cloudflare_worker

data "cloudflare_worker" "example_worker" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  worker_id = "worker_id"
}

data cloudflare_workers

required Expand Collapse
account_id: String

Identifier.

optional Expand Collapse
order?: String

Sort direction.

order_by?: String

Property to sort results by.

max_items?: Int64

Max items to fetch, default: 1000

computed Expand Collapse
result: List[Attributes]

The items returned by the data source

id: String

Immutable ID of the Worker.

created_on: Time

When the Worker was created.

logpush: Bool

Whether logpush is enabled for the Worker.

name: String

Name of the Worker.

observability: Attributes

Observability settings for the Worker.

enabled: Bool

Whether observability is enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).

logs: Attributes

Log settings for the Worker.

destinations: List[String]

A list of destinations where logs will be exported to.

enabled: Bool

Whether logs are enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).

invocation_logs: Bool

Whether invocation logs are enabled for the Worker.

persist: Bool

Whether log persistence is enabled for the Worker.

traces: Attributes

Trace settings for the Worker.

destinations: List[String]

A list of destinations where traces will be exported to.

enabled: Bool

Whether traces are enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).

persist: Bool

Whether trace persistence is enabled for the Worker.

references: Attributes

Other resources that reference the Worker and depend on it existing.

dispatch_namespace_outbounds: List[Attributes]

Other Workers that reference the Worker as an outbound for a dispatch namespace.

namespace_id: String

ID of the dispatch namespace.

namespace_name: String

Name of the dispatch namespace.

worker_id: String

ID of the Worker using the dispatch namespace.

worker_name: String

Name of the Worker using the dispatch namespace.

domains: List[Attributes]

Custom domains connected to the Worker.

id: String

ID of the custom domain.

certificate_id: String

ID of the TLS certificate issued for the custom domain.

hostname: String

Full hostname of the custom domain, including the zone name.

zone_id: String

ID of the zone.

zone_name: String

Name of the zone.

durable_objects: List[Attributes]

Other Workers that reference Durable Object classes implemented by the Worker.

namespace_id: String

ID of the Durable Object namespace being used.

namespace_name: String

Name of the Durable Object namespace being used.

worker_id: String

ID of the Worker using the Durable Object implementation.

worker_name: String

Name of the Worker using the Durable Object implementation.

queues: List[Attributes]

Queues that send messages to the Worker.

queue_consumer_id: String

ID of the queue consumer configuration.

queue_id: String

ID of the queue.

queue_name: String

Name of the queue.

workers: List[Attributes]

Other Workers that reference the Worker using service bindings.

id: String

ID of the referencing Worker.

name: String

Name of the referencing Worker.

subdomain: Attributes

Subdomain settings for the Worker.

enabled: Bool

Whether the *.workers.dev subdomain is enabled for the Worker.

previews_enabled: Bool

Whether preview URLs are enabled for the Worker.

tags: Set[String]

Tags associated with the Worker.

tail_consumers: Set[Attributes]

Other Workers that should consume logs from the Worker.

name: String

Name of the consumer Worker.

updated_on: Time

When the Worker was most recently updated.

deployed_on: Time

When the Worker's most recent deployment was created. null if the Worker has never been deployed.

cloudflare_workers

data "cloudflare_workers" "example_workers" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
}

WorkersBetaWorkersVersions

resource cloudflare_worker_version

required Expand Collapse
account_id: String

Identifier.

worker_id: String

Identifier for the Worker, which can be ID or name.

optional Expand Collapse
compatibility_date?: String

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

main_module?: String

The name of the main module in the modules array (e.g. the name of the module that exports a fetch handler).

migrations?: Attributes

Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.

deleted_classes?: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes?: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes?: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

new_tag?: String

Tag to set as the latest migration tag.

old_tag?: String

Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.

renamed_classes?: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from?: String
to?: String
transferred_classes?: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from?: String
from_script?: String
to?: String
steps?: List[Attributes]

Migrations to apply in order.

deleted_classes?: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes?: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes?: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

renamed_classes?: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from?: String
to?: String
transferred_classes?: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from?: String
from_script?: String
to?: String
modules?: Set[Attributes]

Code, sourcemaps, and other content used at runtime.

This includes _headers and _redirects files used to configure Static Assets. _headers and _redirects files should be included as modules named _headers and _redirects with content type text/plain.

content_base64: String

The base64-encoded module content.

content_type: String

The content type of the module.

name: String

The name of the module.

placement?: Attributes

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

mode?: String

Enables Smart Placement.

region?: String

Cloud region for targeted placement in format 'provider:region'.

hostname?: String

HTTP hostname for targeted placement.

host?: String

TCP host and port for targeted placement.

target?: List[Attributes]

Array of placement targets (currently limited to single target).

region?: String

Cloud region in format 'provider:region'.

hostname?: String

HTTP hostname for targeted placement.

host?: String

TCP host:port for targeted placement.

Deprecatedusage_model?: String

Usage model for the version.

compatibility_flags?: Set[String]

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

annotations?: Attributes

Metadata about the version.

workers_message?: String

Human-readable message about the version.

workers_tag?: String

User-provided identifier for the version.

workers_triggered_by: String

Operation that triggered the creation of the version.

assets?: Attributes

Configuration for assets within a Worker.

_headers and _redirects files should be included as modules named _headers and _redirects with content type text/plain.

config?: Attributes

Configuration for assets within a Worker.

html_handling?: String

Determines the redirects and rewrites of requests for HTML content.

not_found_handling?: String

Determines the response when a request does not match a static asset, and there is no Worker script.

run_worker_first?: List[String]

Contains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either '/' or '!/'. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.

jwt?: String

Token provided upon successful upload of all files from a registered manifest.

bindings?: List[Attributes]

List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.

name: String

A JavaScript variable name for the binding.

type: String

The kind of resource that the binding provides.

instance_name?: String

The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.

namespace?: String

The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.

dataset?: String

The name of the dataset to bind to.

id?: String

Identifier of the D1 database to bind to.

part?: String

The name of the file containing the data content. Only accepted for service worker syntax Workers.

outbound?: Attributes

Outbound worker.

params?: List[Attributes]

Pass information from the Dispatch Worker to the Outbound Worker through the parameters.

name: String

Name of the parameter.

worker?: Attributes

Outbound worker.

entrypoint?: String

Entrypoint to invoke on the outbound worker.

environment?: String

Environment of the outbound worker.

service?: String

Name of the outbound worker.

class_name?: String

The exported class name of the Durable Object.

dispatch_namespace?: String

The dispatch namespace the Durable Object script belongs to.

environment?: String

The environment of the script_name to bind to.

namespace_id?: String

Namespace identifier tag.

script_name?: String

The script where the Durable Object is defined, if it is external to this Worker.

old_name?: String

The old name of the inherited binding. If set, the binding will be renamed from old_name to name in the new version. If not set, the binding will keep the same name between versions.

version_id?: String

Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.

json?: JSON

JSON data to use.

certificate_id?: String

Identifier of the certificate to bind to.

text?: String

The text value to use.

pipeline?: String

Name of the Pipeline to bind to.

queue_name?: String

Name of the Queue to bind to.

simple?: Attributes

The rate limit configuration.

limit: Float64

The limit (requests per period).

period: Int64

The period in seconds.

bucket_name?: String

R2 bucket to bind to.

jurisdiction?: String

The jurisdiction of the R2 bucket.

allowed_destination_addresses?: List[String]

List of allowed destination addresses.

allowed_sender_addresses?: List[String]

List of allowed sender addresses.

destination_address?: String

Destination address for the email.

service?: String

Name of Worker to bind to.

entrypoint?: String

Entrypoint to invoke on the target Worker.

index_name?: String

Name of the Vectorize index to bind to.

secret_name?: String

Name of the secret in the store.

store_id?: String

ID of the store containing the secret.

algorithm?: JSON

Algorithm-specific key parameters. Learn more.

format?: String

Data format of the key. Learn more.

usages?: Set[String]

Allowed operations with the key. Learn more.

key_base64?: String

Base64-encoded key data. Required if format is "raw", "pkcs8", or "spki".

key_jwk?: JSON

Key data in JSON Web Key format. Required if format is "jwk".

workflow_name?: String

Name of the Workflow to bind to.

service_id?: String

Identifier of the VPC service to bind to.

limits?: Attributes

Resource limits enforced at runtime.

cpu_ms: Int64

CPU time limit in milliseconds.

computed Expand Collapse
id: String

Version identifier.

created_on: Time

When the version was created.

number: Int64

The integer version number, starting from one.

source: String

The client used to create the version.

startup_time_ms: Int64

Time in milliseconds spent on Worker startup.

urls: List[String]

All routable URLs that always point to this version. Does not include alias URLs, since aliases can be updated to point to a different version.

cloudflare_worker_version

resource "cloudflare_worker_version" "example_worker_version" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  worker_id = "worker_id"
  annotations = {
    workers_message = "Fixed bug."
    workers_tag = "v1.0.1"
  }
  assets = {
    config = {
      html_handling = "auto-trailing-slash"
      not_found_handling = "404-page"
      run_worker_first = ["string"]
    }
    jwt = "jwt"
  }
  bindings = [{
    name = "MY_ENV_VAR"
    text = "my_data"
    type = "plain_text"
  }]
  compatibility_date = "2021-01-01"
  compatibility_flags = ["nodejs_compat"]
  limits = {
    cpu_ms = 50
  }
  main_module = "index.js"
  migrations = {
    deleted_classes = ["string"]
    new_classes = ["string"]
    new_sqlite_classes = ["string"]
    new_tag = "v2"
    old_tag = "v1"
    renamed_classes = [{
      from = "from"
      to = "to"
    }]
    transferred_classes = [{
      from = "from"
      from_script = "from_script"
      to = "to"
    }]
  }
  modules = [{
    content_base64 = "ZXhwb3J0IGRlZmF1bHQgewogIGFzeW5jIGZldGNoKHJlcXVlc3QsIGVudiwgY3R4KSB7CiAgICByZXR1cm4gbmV3IFJlc3BvbnNlKCdIZWxsbyBXb3JsZCEnKQogIH0KfQ=="
    content_type = "application/javascript+module"
    name = "index.js"
  }]
  placement = {
    mode = "smart"
  }
  usage_model = "standard"
}

data cloudflare_worker_version

required Expand Collapse
version_id: String

Identifier for the version, which can be a UUID, a UUID prefix (minimum length 8), or the literal "latest" to operate on the most recently created version.

account_id: String

Identifier.

worker_id: String

Identifier for the Worker, which can be ID or name.

optional Expand Collapse
include?: String

Whether to include the modules property of the version in the response, which contains code and sourcemap content and may add several megabytes to the response size.

computed Expand Collapse
id: String

Identifier for the version, which can be a UUID, a UUID prefix (minimum length 8), or the literal "latest" to operate on the most recently created version.

compatibility_date: String

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

created_on: Time

When the version was created.

main_module: String

The name of the main module in the modules array (e.g. the name of the module that exports a fetch handler).

number: Int64

The integer version number, starting from one.

source: String

The client used to create the version.

startup_time_ms: Int64

Time in milliseconds spent on Worker startup.

Deprecatedusage_model: String

Usage model for the version.

compatibility_flags: Set[String]

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

urls: List[String]

All routable URLs that always point to this version. Does not include alias URLs, since aliases can be updated to point to a different version.

annotations: Attributes

Metadata about the version.

workers_message: String

Human-readable message about the version.

workers_tag: String

User-provided identifier for the version.

workers_triggered_by: String

Operation that triggered the creation of the version.

assets: Attributes

Configuration for assets within a Worker.

_headers and _redirects files should be included as modules named _headers and _redirects with content type text/plain.

config: Attributes

Configuration for assets within a Worker.

html_handling: String

Determines the redirects and rewrites of requests for HTML content.

not_found_handling: String

Determines the response when a request does not match a static asset, and there is no Worker script.

run_worker_first: List[String]

Contains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either '/' or '!/'. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.

jwt: String

Token provided upon successful upload of all files from a registered manifest.

bindings: List[Attributes]

List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.

name: String

A JavaScript variable name for the binding.

type: String

The kind of resource that the binding provides.

instance_name: String

The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.

namespace: String

The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.

dataset: String

The name of the dataset to bind to.

id: String

Identifier of the D1 database to bind to.

part: String

The name of the file containing the data content. Only accepted for service worker syntax Workers.

outbound: Attributes

Outbound worker.

params: List[Attributes]

Pass information from the Dispatch Worker to the Outbound Worker through the parameters.

name: String

Name of the parameter.

worker: Attributes

Outbound worker.

entrypoint: String

Entrypoint to invoke on the outbound worker.

environment: String

Environment of the outbound worker.

service: String

Name of the outbound worker.

class_name: String

The exported class name of the Durable Object.

dispatch_namespace: String

The dispatch namespace the Durable Object script belongs to.

environment: String

The environment of the script_name to bind to.

namespace_id: String

Namespace identifier tag.

script_name: String

The script where the Durable Object is defined, if it is external to this Worker.

old_name: String

The old name of the inherited binding. If set, the binding will be renamed from old_name to name in the new version. If not set, the binding will keep the same name between versions.

version_id: String

Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.

json: JSON

JSON data to use.

certificate_id: String

Identifier of the certificate to bind to.

text: String

The text value to use.

pipeline: String

Name of the Pipeline to bind to.

queue_name: String

Name of the Queue to bind to.

simple: Attributes

The rate limit configuration.

limit: Float64

The limit (requests per period).

period: Int64

The period in seconds.

bucket_name: String

R2 bucket to bind to.

jurisdiction: String

The jurisdiction of the R2 bucket.

allowed_destination_addresses: List[String]

List of allowed destination addresses.

allowed_sender_addresses: List[String]

List of allowed sender addresses.

destination_address: String

Destination address for the email.

service: String

Name of Worker to bind to.

entrypoint: String

Entrypoint to invoke on the target Worker.

index_name: String

Name of the Vectorize index to bind to.

secret_name: String

Name of the secret in the store.

store_id: String

ID of the store containing the secret.

algorithm: JSON

Algorithm-specific key parameters. Learn more.

format: String

Data format of the key. Learn more.

usages: Set[String]

Allowed operations with the key. Learn more.

key_base64: String

Base64-encoded key data. Required if format is "raw", "pkcs8", or "spki".

key_jwk: JSON

Key data in JSON Web Key format. Required if format is "jwk".

workflow_name: String

Name of the Workflow to bind to.

service_id: String

Identifier of the VPC service to bind to.

limits: Attributes

Resource limits enforced at runtime.

cpu_ms: Int64

CPU time limit in milliseconds.

migrations: Attributes

Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.

deleted_classes: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

new_tag: String

Tag to set as the latest migration tag.

old_tag: String

Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.

renamed_classes: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from: String
to: String
transferred_classes: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from: String
from_script: String
to: String
steps: List[Attributes]

Migrations to apply in order.

deleted_classes: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

renamed_classes: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from: String
to: String
transferred_classes: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from: String
from_script: String
to: String
modules: Set[Attributes]

Code, sourcemaps, and other content used at runtime.

This includes _headers and _redirects files used to configure Static Assets. _headers and _redirects files should be included as modules named _headers and _redirects with content type text/plain.

content_base64: String

The base64-encoded module content.

content_type: String

The content type of the module.

name: String

The name of the module.

placement: Attributes

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

mode: String

Enables Smart Placement.

region: String

Cloud region for targeted placement in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host and port for targeted placement.

target: List[Attributes]

Array of placement targets (currently limited to single target).

region: String

Cloud region in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host:port for targeted placement.

cloudflare_worker_version

data "cloudflare_worker_version" "example_worker_version" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  worker_id = "worker_id"
  version_id = "version_id"
  include = "modules"
}

data cloudflare_worker_versions

required Expand Collapse
account_id: String

Identifier.

worker_id: String

Identifier for the Worker, which can be ID or name.

optional Expand Collapse
max_items?: Int64

Max items to fetch, default: 1000

computed Expand Collapse
result: List[Attributes]

The items returned by the data source

id: String

Version identifier.

created_on: Time

When the version was created.

number: Int64

The integer version number, starting from one.

urls: List[String]

All routable URLs that always point to this version. Does not include alias URLs, since aliases can be updated to point to a different version.

annotations: Attributes

Metadata about the version.

workers_message: String

Human-readable message about the version.

workers_tag: String

User-provided identifier for the version.

workers_triggered_by: String

Operation that triggered the creation of the version.

assets: Attributes

Configuration for assets within a Worker.

_headers and _redirects files should be included as modules named _headers and _redirects with content type text/plain.

config: Attributes

Configuration for assets within a Worker.

html_handling: String

Determines the redirects and rewrites of requests for HTML content.

not_found_handling: String

Determines the response when a request does not match a static asset, and there is no Worker script.

run_worker_first: List[String]

Contains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either '/' or '!/'. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.

jwt: String

Token provided upon successful upload of all files from a registered manifest.

bindings: List[Attributes]

List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.

name: String

A JavaScript variable name for the binding.

type: String

The kind of resource that the binding provides.

instance_name: String

The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.

namespace: String

The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.

dataset: String

The name of the dataset to bind to.

id: String

Identifier of the D1 database to bind to.

part: String

The name of the file containing the data content. Only accepted for service worker syntax Workers.

outbound: Attributes

Outbound worker.

params: List[Attributes]

Pass information from the Dispatch Worker to the Outbound Worker through the parameters.

name: String

Name of the parameter.

worker: Attributes

Outbound worker.

entrypoint: String

Entrypoint to invoke on the outbound worker.

environment: String

Environment of the outbound worker.

service: String

Name of the outbound worker.

class_name: String

The exported class name of the Durable Object.

dispatch_namespace: String

The dispatch namespace the Durable Object script belongs to.

environment: String

The environment of the script_name to bind to.

namespace_id: String

Namespace identifier tag.

script_name: String

The script where the Durable Object is defined, if it is external to this Worker.

old_name: String

The old name of the inherited binding. If set, the binding will be renamed from old_name to name in the new version. If not set, the binding will keep the same name between versions.

version_id: String

Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.

json: JSON

JSON data to use.

certificate_id: String

Identifier of the certificate to bind to.

text: String

The text value to use.

pipeline: String

Name of the Pipeline to bind to.

queue_name: String

Name of the Queue to bind to.

simple: Attributes

The rate limit configuration.

limit: Float64

The limit (requests per period).

period: Int64

The period in seconds.

bucket_name: String

R2 bucket to bind to.

jurisdiction: String

The jurisdiction of the R2 bucket.

allowed_destination_addresses: List[String]

List of allowed destination addresses.

allowed_sender_addresses: List[String]

List of allowed sender addresses.

destination_address: String

Destination address for the email.

service: String

Name of Worker to bind to.

entrypoint: String

Entrypoint to invoke on the target Worker.

index_name: String

Name of the Vectorize index to bind to.

secret_name: String

Name of the secret in the store.

store_id: String

ID of the store containing the secret.

algorithm: JSON

Algorithm-specific key parameters. Learn more.

format: String

Data format of the key. Learn more.

usages: Set[String]

Allowed operations with the key. Learn more.

key_base64: String

Base64-encoded key data. Required if format is "raw", "pkcs8", or "spki".

key_jwk: JSON

Key data in JSON Web Key format. Required if format is "jwk".

workflow_name: String

Name of the Workflow to bind to.

service_id: String

Identifier of the VPC service to bind to.

compatibility_date: String

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

compatibility_flags: Set[String]

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

limits: Attributes

Resource limits enforced at runtime.

cpu_ms: Int64

CPU time limit in milliseconds.

main_module: String

The name of the main module in the modules array (e.g. the name of the module that exports a fetch handler).

migrations: Attributes

Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.

deleted_classes: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

new_tag: String

Tag to set as the latest migration tag.

old_tag: String

Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.

renamed_classes: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from: String
to: String
transferred_classes: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from: String
from_script: String
to: String
steps: List[Attributes]

Migrations to apply in order.

deleted_classes: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

renamed_classes: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from: String
to: String
transferred_classes: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from: String
from_script: String
to: String
modules: Set[Attributes]

Code, sourcemaps, and other content used at runtime.

This includes _headers and _redirects files used to configure Static Assets. _headers and _redirects files should be included as modules named _headers and _redirects with content type text/plain.

content_base64: String

The base64-encoded module content.

content_type: String

The content type of the module.

name: String

The name of the module.

placement: Attributes

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

mode: String

Enables Smart Placement.

region: String

Cloud region for targeted placement in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host and port for targeted placement.

target: List[Attributes]

Array of placement targets (currently limited to single target).

region: String

Cloud region in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host:port for targeted placement.

source: String

The client used to create the version.

startup_time_ms: Int64

Time in milliseconds spent on Worker startup.

Deprecatedusage_model: String

Usage model for the version.

cloudflare_worker_versions

data "cloudflare_worker_versions" "example_worker_versions" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  worker_id = "worker_id"
}

WorkersRoutes

resource cloudflare_workers_route

required Expand Collapse
zone_id: String

Identifier.

pattern: String

Pattern to match incoming requests against. Learn more.

optional Expand Collapse
script?: String

Name of the script to run if the route matches.

computed Expand Collapse
id: String

Identifier.

cloudflare_workers_route

resource "cloudflare_workers_route" "example_workers_route" {
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
  pattern = "example.com/*"
  script = "my-workers-script"
}

data cloudflare_workers_route

required Expand Collapse
route_id: String

Identifier.

zone_id: String

Identifier.

computed Expand Collapse
id: String

Identifier.

pattern: String

Pattern to match incoming requests against. Learn more.

script: String

Name of the script to run if the route matches.

cloudflare_workers_route

data "cloudflare_workers_route" "example_workers_route" {
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
  route_id = "023e105f4ecef8ad9ca31a8372d0c353"
}

data cloudflare_workers_routes

required Expand Collapse
zone_id: String

Identifier.

optional Expand Collapse
max_items?: Int64

Max items to fetch, default: 1000

computed Expand Collapse
result: List[Attributes]

The items returned by the data source

id: String

Identifier.

pattern: String

Pattern to match incoming requests against. Learn more.

script: String

Name of the script to run if the route matches.

cloudflare_workers_routes

data "cloudflare_workers_routes" "example_workers_routes" {
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
}

WorkersScripts

resource cloudflare_workers_script

required Expand Collapse
script_name: String

Name of the script, used in URLs and route configuration.

account_id: String

Identifier.

metadata: Attributes

JSON-encoded metadata about the uploaded parts and Worker configuration.

annotations?: Attributes

Annotations for the version created by this upload.

workers_message?: String

Human-readable message about the version.

workers_tag?: String

User-provided identifier for the version.

assets?: Attributes

Configuration for assets within a Worker.

config?: Attributes

Configuration for assets within a Worker.

headers?: String

The contents of a _headers file (used to attach custom headers on asset responses).

redirects?: String

The contents of a _redirects file (used to apply redirects or proxy paths ahead of asset serving).

html_handling?: String

Determines the redirects and rewrites of requests for HTML content.

not_found_handling?: String

Determines the response when a request does not match a static asset, and there is no Worker script.

run_worker_first?: List[String]

Contains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either '/' or '!/'. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.

Deprecatedserve_directly?: Bool

When true and the incoming request matches an asset, that will be served instead of invoking the Worker script. When false, requests will always invoke the Worker script.

jwt?: String

Token provided upon successful upload of all files from a registered manifest.

bindings?: List[Attributes]

List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.

name: String

A JavaScript variable name for the binding.

type: String

The kind of resource that the binding provides.

instance_name?: String

The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.

namespace?: String

The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.

dataset?: String

The name of the dataset to bind to.

id?: String

Identifier of the D1 database to bind to.

part?: String

The name of the file containing the data content. Only accepted for service worker syntax Workers.

outbound?: Attributes

Outbound worker.

params?: List[Attributes]

Pass information from the Dispatch Worker to the Outbound Worker through the parameters.

name: String

Name of the parameter.

worker?: Attributes

Outbound worker.

entrypoint?: String

Entrypoint to invoke on the outbound worker.

environment?: String

Environment of the outbound worker.

service?: String

Name of the outbound worker.

class_name?: String

The exported class name of the Durable Object.

dispatch_namespace?: String

The dispatch namespace the Durable Object script belongs to.

environment?: String

The environment of the script_name to bind to.

namespace_id?: String

Namespace identifier tag.

script_name?: String

The script where the Durable Object is defined, if it is external to this Worker.

old_name?: String

The old name of the inherited binding. If set, the binding will be renamed from old_name to name in the new version. If not set, the binding will keep the same name between versions.

version_id?: String

Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.

json?: JSON

JSON data to use.

certificate_id?: String

Identifier of the certificate to bind to.

text?: String

The text value to use.

pipeline?: String

Name of the Pipeline to bind to.

queue_name?: String

Name of the Queue to bind to.

simple?: Attributes

The rate limit configuration.

limit: Float64

The limit (requests per period).

period: Int64

The period in seconds.

bucket_name?: String

R2 bucket to bind to.

jurisdiction?: String

The jurisdiction of the R2 bucket.

allowed_destination_addresses?: List[String]

List of allowed destination addresses.

allowed_sender_addresses?: List[String]

List of allowed sender addresses.

destination_address?: String

Destination address for the email.

service?: String

Name of Worker to bind to.

entrypoint?: String

Entrypoint to invoke on the target Worker.

index_name?: String

Name of the Vectorize index to bind to.

secret_name?: String

Name of the secret in the store.

store_id?: String

ID of the store containing the secret.

algorithm?: JSON

Algorithm-specific key parameters. Learn more.

format?: String

Data format of the key. Learn more.

usages?: Set[String]

Allowed operations with the key. Learn more.

key_base64?: String

Base64-encoded key data. Required if format is "raw", "pkcs8", or "spki".

key_jwk?: JSON

Key data in JSON Web Key format. Required if format is "jwk".

workflow_name?: String

Name of the Workflow to bind to.

service_id?: String

Identifier of the VPC service to bind to.

body_part?: String

Name of the uploaded file that contains the script (e.g. the file adding a listener to the fetch event). Indicates a service worker syntax Worker.

compatibility_date?: String

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

compatibility_flags?: Set[String]

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

keep_assets?: Bool

Retain assets which exist for a previously uploaded Worker version; used in lieu of providing a completion token.

keep_bindings?: Set[String]

List of binding types to keep from previous_upload.

limits?: Attributes

Limits to apply for this Worker.

cpu_ms?: Int64

The amount of CPU time this Worker can use in milliseconds.

logpush?: Bool

Whether Logpush is turned on for the Worker.

main_module?: String

Name of the uploaded file that contains the main module (e.g. the file exporting a fetch handler). Indicates a module syntax Worker.

migrations?: Attributes

Migrations to apply for Durable Objects associated with this Worker.

deleted_classes?: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes?: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes?: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

new_tag?: String

Tag to set as the latest migration tag.

old_tag?: String

Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.

renamed_classes?: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from?: String
to?: String
transferred_classes?: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from?: String
from_script?: String
to?: String
steps?: List[Attributes]

Migrations to apply in order.

deleted_classes?: List[String]

A list of classes to delete Durable Object namespaces from.

new_classes?: List[String]

A list of classes to create Durable Object namespaces from.

new_sqlite_classes?: List[String]

A list of classes to create Durable Object namespaces with SQLite from.

renamed_classes?: List[Attributes]

A list of classes with Durable Object namespaces that were renamed.

from?: String
to?: String
transferred_classes?: List[Attributes]

A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.

from?: String
from_script?: String
to?: String
observability?: Attributes

Observability settings for the Worker.

enabled: Bool

Whether observability is enabled for the Worker.

head_sampling_rate?: Float64

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

logs?: Attributes

Log settings for the Worker.

enabled: Bool

Whether logs are enabled for the Worker.

invocation_logs: Bool

Whether invocation logs are enabled for the Worker.

destinations?: List[String]

A list of destinations where logs will be exported to.

head_sampling_rate?: Float64

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist?: Bool

Whether log persistence is enabled for the Worker.

traces?: Attributes

Trace settings for the Worker.

destinations?: List[String]

A list of destinations where traces will be exported to.

enabled?: Bool

Whether traces are enabled for the Worker.

head_sampling_rate?: Float64

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist?: Bool

Whether trace persistence is enabled for the Worker.

placement?: Attributes

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

mode?: String

Enables Smart Placement.

last_analyzed_at: Time

The last time the script was analyzed for Smart Placement.

status: String

Status of Smart Placement.

region?: String

Cloud region for targeted placement in format 'provider:region'.

hostname?: String

HTTP hostname for targeted placement.

host?: String

TCP host and port for targeted placement.

target?: List[Attributes]

Array of placement targets (currently limited to single target).

region?: String

Cloud region in format 'provider:region'.

hostname?: String

HTTP hostname for targeted placement.

host?: String

TCP host:port for targeted placement.

tags?: Set[String]

List of strings to use as tags for this Worker.

tail_consumers?: Set[Attributes]

List of Workers that will consume logs from the attached Worker.

service: String

Name of Worker that is to be the consumer.

environment?: String

Optional environment if the Worker utilizes one.

namespace?: String

Optional dispatch namespace the script belongs to.

usage_model?: String

Usage model for the Worker invocations.

optional Expand Collapse
files?: Set[String]

An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as main_module or body_part by filename.
Possible Content-Type(s) are: application/javascript+module, text/javascript+module, application/javascript, text/javascript, text/x-python, text/x-python-requirement, application/wasm, text/plain, application/octet-stream, application/source-map.

computed Expand Collapse
id: String

Name of the script, used in URLs and route configuration.

compatibility_date: String

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

created_on: Time

When the script was created.

entry_point: String

The entry point for the script.

etag: String

Hashed script content, can be used in a If-None-Match header when updating.

has_assets: Bool

Whether a Worker contains assets.

has_modules: Bool

Whether a Worker contains modules.

last_deployed_from: String

The client most recently used to deploy this Worker.

logpush: Bool

Whether Logpush is turned on for the Worker.

migration_tag: String

The tag of the Durable Object migration that was most recently applied for this Worker.

modified_on: Time

When the script was last modified.

Deprecatedplacement_mode: String
Deprecatedplacement_status: String
startup_time_ms: Int64
tag: String

The immutable ID of the script.

usage_model: String

Usage model for the Worker invocations.

compatibility_flags: Set[String]

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

handlers: List[String]

The names of handlers exported as part of the default export.

tags: Set[String]

Tags associated with the Worker.

named_handlers: List[Attributes]

Named exports, such as Durable Object class implementations and named entrypoints.

handlers: List[String]

The names of handlers exported as part of the named export.

name: String

The name of the export.

observability: Attributes

Observability settings for the Worker.

enabled: Bool

Whether observability is enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

logs: Attributes

Log settings for the Worker.

enabled: Bool

Whether logs are enabled for the Worker.

invocation_logs: Bool

Whether invocation logs are enabled for the Worker.

destinations: List[String]

A list of destinations where logs will be exported to.

head_sampling_rate: Float64

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: Bool

Whether log persistence is enabled for the Worker.

traces: Attributes

Trace settings for the Worker.

destinations: List[String]

A list of destinations where traces will be exported to.

enabled: Bool

Whether traces are enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: Bool

Whether trace persistence is enabled for the Worker.

placement: Attributes

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

mode: String

Enables Smart Placement.

last_analyzed_at: Time

The last time the script was analyzed for Smart Placement.

status: String

Status of Smart Placement.

region: String

Cloud region for targeted placement in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host and port for targeted placement.

target: List[Attributes]

Array of placement targets (currently limited to single target).

region: String

Cloud region in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host:port for targeted placement.

tail_consumers: Set[Attributes]

List of Workers that will consume logs from the attached Worker.

service: String

Name of Worker that is to be the consumer.

environment: String

Optional environment if the Worker utilizes one.

namespace: String

Optional dispatch namespace the script belongs to.

cloudflare_workers_script

resource "cloudflare_workers_script" "example_workers_script" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
  metadata = {
    annotations = {
      workers_message = "Fixed bug."
      workers_tag = "v1.0.1"
    }
    assets = {
      config = {
        headers = <<EOT
        /dashboard/*
        X-Frame-Options: DENY

        /static/*
        Access-Control-Allow-Origin: *
        EOT
        redirects = <<EOT
        /foo /bar 301
        /news/* /blog/:splat
        EOT
        html_handling = "auto-trailing-slash"
        not_found_handling = "404-page"
        run_worker_first = ["string"]
        serve_directly = true
      }
      jwt = "jwt"
    }
    bindings = [{
      name = "MY_ENV_VAR"
      text = "my_data"
      type = "plain_text"
    }]
    body_part = "worker.js"
    compatibility_date = "2021-01-01"
    compatibility_flags = ["nodejs_compat"]
    keep_assets = false
    keep_bindings = ["string"]
    limits = {
      cpu_ms = 50
    }
    logpush = false
    main_module = "worker.js"
    migrations = {
      deleted_classes = ["string"]
      new_classes = ["string"]
      new_sqlite_classes = ["string"]
      new_tag = "v2"
      old_tag = "v1"
      renamed_classes = [{
        from = "from"
        to = "to"
      }]
      transferred_classes = [{
        from = "from"
        from_script = "from_script"
        to = "to"
      }]
    }
    observability = {
      enabled = true
      head_sampling_rate = 0.1
      logs = {
        enabled = true
        invocation_logs = true
        destinations = ["cloudflare"]
        head_sampling_rate = 0.1
        persist = true
      }
      traces = {
        destinations = ["cloudflare"]
        enabled = true
        head_sampling_rate = 0.1
        persist = true
      }
    }
    placement = {
      mode = "smart"
    }
    tags = ["string"]
    tail_consumers = [{
      service = "my-log-consumer"
      environment = "production"
      namespace = "my-namespace"
    }]
    usage_model = "standard"
  }
  files = ["Example data"]
}

data cloudflare_workers_script

required Expand Collapse
account_id: String

Identifier.

optional Expand Collapse
script_name?: String

Name of the script, used in URLs and route configuration.

filter?: Attributes
tags?: String

Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'.

computed Expand Collapse
id: String

Name of the script, used in URLs and route configuration.

script: String

cloudflare_workers_script

data "cloudflare_workers_script" "example_workers_script" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
}

data cloudflare_workers_scripts

required Expand Collapse
account_id: String

Identifier.

optional Expand Collapse
tags?: String

Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'.

max_items?: Int64

Max items to fetch, default: 1000

computed Expand Collapse
result: List[Attributes]

The items returned by the data source

id: String

The name used to identify the script.

compatibility_date: String

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

compatibility_flags: Set[String]

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

created_on: Time

When the script was created.

etag: String

Hashed script content, can be used in a If-None-Match header when updating.

handlers: List[String]

The names of handlers exported as part of the default export.

has_assets: Bool

Whether a Worker contains assets.

has_modules: Bool

Whether a Worker contains modules.

last_deployed_from: String

The client most recently used to deploy this Worker.

logpush: Bool

Whether Logpush is turned on for the Worker.

migration_tag: String

The tag of the Durable Object migration that was most recently applied for this Worker.

modified_on: Time

When the script was last modified.

named_handlers: List[Attributes]

Named exports, such as Durable Object class implementations and named entrypoints.

handlers: List[String]

The names of handlers exported as part of the named export.

name: String

The name of the export.

observability: Attributes

Observability settings for the Worker.

enabled: Bool

Whether observability is enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

logs: Attributes

Log settings for the Worker.

enabled: Bool

Whether logs are enabled for the Worker.

invocation_logs: Bool

Whether invocation logs are enabled for the Worker.

destinations: List[String]

A list of destinations where logs will be exported to.

head_sampling_rate: Float64

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: Bool

Whether log persistence is enabled for the Worker.

traces: Attributes

Trace settings for the Worker.

destinations: List[String]

A list of destinations where traces will be exported to.

enabled: Bool

Whether traces are enabled for the Worker.

head_sampling_rate: Float64

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: Bool

Whether trace persistence is enabled for the Worker.

placement: Attributes

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

mode: String

Enables Smart Placement.

last_analyzed_at: Time

The last time the script was analyzed for Smart Placement.

status: String

Status of Smart Placement.

region: String

Cloud region for targeted placement in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host and port for targeted placement.

target: List[Attributes]

Array of placement targets (currently limited to single target).

region: String

Cloud region in format 'provider:region'.

hostname: String

HTTP hostname for targeted placement.

host: String

TCP host:port for targeted placement.

Deprecatedplacement_mode: String
Deprecatedplacement_status: String
routes: List[Attributes]

Routes associated with the Worker.

id: String

Identifier.

pattern: String

Pattern to match incoming requests against. Learn more.

script: String

Name of the script to run if the route matches.

tag: String

The immutable ID of the script.

tags: Set[String]

Tags associated with the Worker.

tail_consumers: Set[Attributes]

List of Workers that will consume logs from the attached Worker.

service: String

Name of Worker that is to be the consumer.

environment: String

Optional environment if the Worker utilizes one.

namespace: String

Optional dispatch namespace the script belongs to.

usage_model: String

Usage model for the Worker invocations.

cloudflare_workers_scripts

data "cloudflare_workers_scripts" "example_workers_scripts" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  tags = "production:yes,staging:no"
}

WorkersScriptsSubdomain

resource cloudflare_workers_script_subdomain

required Expand Collapse
account_id: String

Identifier.

script_name: String

Name of the script, used in URLs and route configuration.

enabled: Bool

Whether the Worker should be available on the workers.dev subdomain.

optional Expand Collapse
previews_enabled?: Bool

Whether the Worker's Preview URLs should be available on the workers.dev subdomain.

cloudflare_workers_script_subdomain

resource "cloudflare_workers_script_subdomain" "example_workers_script_subdomain" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
  enabled = true
  previews_enabled = false
}

data cloudflare_workers_script_subdomain

required Expand Collapse
account_id: String

Identifier.

script_name: String

Name of the script, used in URLs and route configuration.

computed Expand Collapse
enabled: Bool

Whether the Worker is available on the workers.dev subdomain.

previews_enabled: Bool

Whether the Worker's Preview URLs are available on the workers.dev subdomain.

cloudflare_workers_script_subdomain

data "cloudflare_workers_script_subdomain" "example_workers_script_subdomain" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
}

WorkersScriptsSchedules

resource cloudflare_workers_cron_trigger

required Expand Collapse
script_name: String

Name of the script, used in URLs and route configuration.

account_id: String

Identifier.

body: List[Attributes]
cron: String
created_on: String
modified_on: String
computed Expand Collapse
id: String

Name of the script, used in URLs and route configuration.

schedules: List[Attributes]
cron: String
created_on: String
modified_on: String

cloudflare_workers_cron_trigger

resource "cloudflare_workers_cron_trigger" "example_workers_cron_trigger" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
  body = [{
    cron = "*/30 * * * *"
  }]
}

data cloudflare_workers_cron_trigger

required Expand Collapse
script_name: String

Name of the script, used in URLs and route configuration.

account_id: String

Identifier.

computed Expand Collapse
id: String

Name of the script, used in URLs and route configuration.

schedules: List[Attributes]
cron: String
created_on: String
modified_on: String

cloudflare_workers_cron_trigger

data "cloudflare_workers_cron_trigger" "example_workers_cron_trigger" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
}

WorkersScriptsDeployments

resource cloudflare_workers_deployment

required Expand Collapse
account_id: String

Identifier.

script_name: String

Name of the script, used in URLs and route configuration.

strategy: String
versions: List[Attributes]
percentage: Float64
version_id: String
optional Expand Collapse
annotations?: Attributes
workers_message?: String

Human-readable message about the deployment. Truncated to 100 bytes.

workers_triggered_by: String

Operation that triggered the creation of the deployment.

computed Expand Collapse
id: String
author_email: String
created_on: Time
source: String

cloudflare_workers_deployment

resource "cloudflare_workers_deployment" "example_workers_deployment" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
  strategy = "percentage"
  versions = [{
    percentage = 100
    version_id = "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
  }]
  annotations = {
    workers_message = "Deploy bug fix."
  }
}

data cloudflare_workers_deployment

required Expand Collapse
deployment_id: String
account_id: String

Identifier.

script_name: String

Name of the script, used in URLs and route configuration.

computed Expand Collapse
id: String
author_email: String
created_on: Time
source: String
strategy: String
annotations: Attributes
workers_message: String

Human-readable message about the deployment. Truncated to 100 bytes.

workers_triggered_by: String

Operation that triggered the creation of the deployment.

versions: List[Attributes]
percentage: Float64
version_id: String

cloudflare_workers_deployment

data "cloudflare_workers_deployment" "example_workers_deployment" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  script_name = "this-is_my_script-01"
  deployment_id = "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}

WorkersDomains

resource cloudflare_workers_custom_domain

required Expand Collapse
account_id: String

Identifier.

hostname: String

Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.

service: String

Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.

optional Expand Collapse
Deprecatedenvironment?: String

Worker environment associated with the domain.

zone_id?: String

ID of the zone containing the domain hostname.

zone_name?: String

Name of the zone containing the domain hostname.

computed Expand Collapse
id: String

Immutable ID of the domain.

cert_id: String

ID of the TLS certificate issued for the domain.

cloudflare_workers_custom_domain

resource "cloudflare_workers_custom_domain" "example_workers_custom_domain" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  hostname = "app.example.com"
  service = "my-worker"
  environment = "production"
  zone_id = "593c9c94de529bbbfaac7c53ced0447d"
  zone_name = "example.com"
}

data cloudflare_workers_custom_domain

required Expand Collapse
account_id: String

Identifier.

optional Expand Collapse
domain_id?: String

ID of the domain.

filter?: Attributes
environment?: String

Worker environment associated with the domain.

hostname?: String

Hostname of the domain.

service?: String

Name of the Worker associated with the domain.

zone_id?: String

ID of the zone containing the domain hostname.

zone_name?: String

Name of the zone containing the domain hostname.

computed Expand Collapse
id: String

ID of the domain.

cert_id: String

ID of the TLS certificate issued for the domain.

Deprecatedenvironment: String

Worker environment associated with the domain.

hostname: String

Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.

service: String

Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.

zone_id: String

ID of the zone containing the domain hostname.

zone_name: String

Name of the zone containing the domain hostname.

cloudflare_workers_custom_domain

data "cloudflare_workers_custom_domain" "example_workers_custom_domain" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  domain_id = "dbe10b4bc17c295377eabd600e1787fd"
}

data cloudflare_workers_custom_domains

required Expand Collapse
account_id: String

Identifier.

optional Expand Collapse
environment?: String

Worker environment associated with the domain.

hostname?: String

Hostname of the domain.

service?: String

Name of the Worker associated with the domain.

zone_id?: String

ID of the zone containing the domain hostname.

zone_name?: String

Name of the zone containing the domain hostname.

max_items?: Int64

Max items to fetch, default: 1000

computed Expand Collapse
result: List[Attributes]

The items returned by the data source

id: String

Immutable ID of the domain.

cert_id: String

ID of the TLS certificate issued for the domain.

Deprecatedenvironment: String

Worker environment associated with the domain.

hostname: String

Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.

service: String

Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.

zone_id: String

ID of the zone containing the domain hostname.

zone_name: String

Name of the zone containing the domain hostname.

cloudflare_workers_custom_domains

data "cloudflare_workers_custom_domains" "example_workers_custom_domains" {
  account_id = "023e105f4ecef8ad9ca31a8372d0c353"
  environment = "production"
  hostname = "app.example.com"
  service = "my-worker"
  zone_id = "593c9c94de529bbbfaac7c53ced0447d"
  zone_name = "example.com"
}