1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. Worker
Cloudflare v6.8.0 published on Saturday, Aug 30, 2025 by Pulumi

cloudflare.Worker

Explore with Pulumi AI

cloudflare logo
Cloudflare v6.8.0 published on Saturday, Aug 30, 2025 by Pulumi

    Example Usage

    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    resources:
      exampleWorker:
        type: cloudflare:Worker
        name: example_worker
        properties:
          accountId: 023e105f4ecef8ad9ca31a8372d0c353
          name: my-worker
          logpush: true
          observability:
            enabled: true
            head_sampling_rate: 0
            logs:
              enabled: true
              headSamplingRate: 0
              invocationLogs: true
          subdomain:
            enabled: true
            previews_enabled: true
          tags:
            - my-team
            - my-public-api
          tailConsumers:
            - name: my-tail-consumer
    

    Create Worker Resource

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

    Constructor syntax

    new Worker(name: string, args: WorkerArgs, opts?: CustomResourceOptions);
    @overload
    def Worker(resource_name: str,
               args: WorkerArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Worker(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               account_id: Optional[str] = None,
               name: Optional[str] = None,
               logpush: Optional[bool] = None,
               observability: Optional[WorkerObservabilityArgs] = None,
               subdomain: Optional[WorkerSubdomainArgs] = None,
               tags: Optional[Sequence[str]] = None,
               tail_consumers: Optional[Sequence[WorkerTailConsumerArgs]] = None)
    func NewWorker(ctx *Context, name string, args WorkerArgs, opts ...ResourceOption) (*Worker, error)
    public Worker(string name, WorkerArgs args, CustomResourceOptions? opts = null)
    public Worker(String name, WorkerArgs args)
    public Worker(String name, WorkerArgs args, CustomResourceOptions options)
    
    type: cloudflare:Worker
    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 WorkerArgs
    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 WorkerArgs
    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 WorkerArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args WorkerArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args WorkerArgs
    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 workerResource = new Cloudflare.Worker("workerResource", new()
    {
        AccountId = "string",
        Name = "string",
        Logpush = false,
        Observability = new Cloudflare.Inputs.WorkerObservabilityArgs
        {
            Enabled = false,
            HeadSamplingRate = 0,
            Logs = new Cloudflare.Inputs.WorkerObservabilityLogsArgs
            {
                Enabled = false,
                HeadSamplingRate = 0,
                InvocationLogs = false,
            },
        },
        Subdomain = new Cloudflare.Inputs.WorkerSubdomainArgs
        {
            Enabled = false,
            PreviewsEnabled = false,
        },
        Tags = new[]
        {
            "string",
        },
        TailConsumers = new[]
        {
            new Cloudflare.Inputs.WorkerTailConsumerArgs
            {
                Name = "string",
            },
        },
    });
    
    example, err := cloudflare.NewWorker(ctx, "workerResource", &cloudflare.WorkerArgs{
    	AccountId: pulumi.String("string"),
    	Name:      pulumi.String("string"),
    	Logpush:   pulumi.Bool(false),
    	Observability: &cloudflare.WorkerObservabilityArgs{
    		Enabled:          pulumi.Bool(false),
    		HeadSamplingRate: pulumi.Float64(0),
    		Logs: &cloudflare.WorkerObservabilityLogsArgs{
    			Enabled:          pulumi.Bool(false),
    			HeadSamplingRate: pulumi.Float64(0),
    			InvocationLogs:   pulumi.Bool(false),
    		},
    	},
    	Subdomain: &cloudflare.WorkerSubdomainArgs{
    		Enabled:         pulumi.Bool(false),
    		PreviewsEnabled: pulumi.Bool(false),
    	},
    	Tags: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	TailConsumers: cloudflare.WorkerTailConsumerArray{
    		&cloudflare.WorkerTailConsumerArgs{
    			Name: pulumi.String("string"),
    		},
    	},
    })
    
    var workerResource = new Worker("workerResource", WorkerArgs.builder()
        .accountId("string")
        .name("string")
        .logpush(false)
        .observability(WorkerObservabilityArgs.builder()
            .enabled(false)
            .headSamplingRate(0.0)
            .logs(WorkerObservabilityLogsArgs.builder()
                .enabled(false)
                .headSamplingRate(0.0)
                .invocationLogs(false)
                .build())
            .build())
        .subdomain(WorkerSubdomainArgs.builder()
            .enabled(false)
            .previewsEnabled(false)
            .build())
        .tags("string")
        .tailConsumers(WorkerTailConsumerArgs.builder()
            .name("string")
            .build())
        .build());
    
    worker_resource = cloudflare.Worker("workerResource",
        account_id="string",
        name="string",
        logpush=False,
        observability={
            "enabled": False,
            "head_sampling_rate": 0,
            "logs": {
                "enabled": False,
                "head_sampling_rate": 0,
                "invocation_logs": False,
            },
        },
        subdomain={
            "enabled": False,
            "previews_enabled": False,
        },
        tags=["string"],
        tail_consumers=[{
            "name": "string",
        }])
    
    const workerResource = new cloudflare.Worker("workerResource", {
        accountId: "string",
        name: "string",
        logpush: false,
        observability: {
            enabled: false,
            headSamplingRate: 0,
            logs: {
                enabled: false,
                headSamplingRate: 0,
                invocationLogs: false,
            },
        },
        subdomain: {
            enabled: false,
            previewsEnabled: false,
        },
        tags: ["string"],
        tailConsumers: [{
            name: "string",
        }],
    });
    
    type: cloudflare:Worker
    properties:
        accountId: string
        logpush: false
        name: string
        observability:
            enabled: false
            headSamplingRate: 0
            logs:
                enabled: false
                headSamplingRate: 0
                invocationLogs: false
        subdomain:
            enabled: false
            previewsEnabled: false
        tags:
            - string
        tailConsumers:
            - name: string
    

    Worker 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 Worker resource accepts the following input properties:

    AccountId string
    Identifier.
    Name string
    Name of the Worker.
    Logpush bool
    Whether logpush is enabled for the Worker.
    Observability WorkerObservability
    Observability settings for the Worker.
    Subdomain WorkerSubdomain
    Subdomain settings for the Worker.
    Tags List<string>
    Tags associated with the Worker.
    TailConsumers List<WorkerTailConsumer>
    Other Workers that should consume logs from the Worker.
    AccountId string
    Identifier.
    Name string
    Name of the Worker.
    Logpush bool
    Whether logpush is enabled for the Worker.
    Observability WorkerObservabilityArgs
    Observability settings for the Worker.
    Subdomain WorkerSubdomainArgs
    Subdomain settings for the Worker.
    Tags []string
    Tags associated with the Worker.
    TailConsumers []WorkerTailConsumerArgs
    Other Workers that should consume logs from the Worker.
    accountId String
    Identifier.
    name String
    Name of the Worker.
    logpush Boolean
    Whether logpush is enabled for the Worker.
    observability WorkerObservability
    Observability settings for the Worker.
    subdomain WorkerSubdomain
    Subdomain settings for the Worker.
    tags List<String>
    Tags associated with the Worker.
    tailConsumers List<WorkerTailConsumer>
    Other Workers that should consume logs from the Worker.
    accountId string
    Identifier.
    name string
    Name of the Worker.
    logpush boolean
    Whether logpush is enabled for the Worker.
    observability WorkerObservability
    Observability settings for the Worker.
    subdomain WorkerSubdomain
    Subdomain settings for the Worker.
    tags string[]
    Tags associated with the Worker.
    tailConsumers WorkerTailConsumer[]
    Other Workers that should consume logs from the Worker.
    account_id str
    Identifier.
    name str
    Name of the Worker.
    logpush bool
    Whether logpush is enabled for the Worker.
    observability WorkerObservabilityArgs
    Observability settings for the Worker.
    subdomain WorkerSubdomainArgs
    Subdomain settings for the Worker.
    tags Sequence[str]
    Tags associated with the Worker.
    tail_consumers Sequence[WorkerTailConsumerArgs]
    Other Workers that should consume logs from the Worker.
    accountId String
    Identifier.
    name String
    Name of the Worker.
    logpush Boolean
    Whether logpush is enabled for the Worker.
    observability Property Map
    Observability settings for the Worker.
    subdomain Property Map
    Subdomain settings for the Worker.
    tags List<String>
    Tags associated with the Worker.
    tailConsumers List<Property Map>
    Other Workers that should consume logs from the Worker.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Worker resource produces the following output properties:

    CreatedOn string
    When the Worker was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    UpdatedOn string
    When the Worker was most recently updated.
    CreatedOn string
    When the Worker was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    UpdatedOn string
    When the Worker was most recently updated.
    createdOn String
    When the Worker was created.
    id String
    The provider-assigned unique ID for this managed resource.
    updatedOn String
    When the Worker was most recently updated.
    createdOn string
    When the Worker was created.
    id string
    The provider-assigned unique ID for this managed resource.
    updatedOn string
    When the Worker was most recently updated.
    created_on str
    When the Worker was created.
    id str
    The provider-assigned unique ID for this managed resource.
    updated_on str
    When the Worker was most recently updated.
    createdOn String
    When the Worker was created.
    id String
    The provider-assigned unique ID for this managed resource.
    updatedOn String
    When the Worker was most recently updated.

    Look up Existing Worker Resource

    Get an existing Worker 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?: WorkerState, opts?: CustomResourceOptions): Worker
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            created_on: Optional[str] = None,
            logpush: Optional[bool] = None,
            name: Optional[str] = None,
            observability: Optional[WorkerObservabilityArgs] = None,
            subdomain: Optional[WorkerSubdomainArgs] = None,
            tags: Optional[Sequence[str]] = None,
            tail_consumers: Optional[Sequence[WorkerTailConsumerArgs]] = None,
            updated_on: Optional[str] = None) -> Worker
    func GetWorker(ctx *Context, name string, id IDInput, state *WorkerState, opts ...ResourceOption) (*Worker, error)
    public static Worker Get(string name, Input<string> id, WorkerState? state, CustomResourceOptions? opts = null)
    public static Worker get(String name, Output<String> id, WorkerState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:Worker    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    AccountId string
    Identifier.
    CreatedOn string
    When the Worker was created.
    Logpush bool
    Whether logpush is enabled for the Worker.
    Name string
    Name of the Worker.
    Observability WorkerObservability
    Observability settings for the Worker.
    Subdomain WorkerSubdomain
    Subdomain settings for the Worker.
    Tags List<string>
    Tags associated with the Worker.
    TailConsumers List<WorkerTailConsumer>
    Other Workers that should consume logs from the Worker.
    UpdatedOn string
    When the Worker was most recently updated.
    AccountId string
    Identifier.
    CreatedOn string
    When the Worker was created.
    Logpush bool
    Whether logpush is enabled for the Worker.
    Name string
    Name of the Worker.
    Observability WorkerObservabilityArgs
    Observability settings for the Worker.
    Subdomain WorkerSubdomainArgs
    Subdomain settings for the Worker.
    Tags []string
    Tags associated with the Worker.
    TailConsumers []WorkerTailConsumerArgs
    Other Workers that should consume logs from the Worker.
    UpdatedOn string
    When the Worker was most recently updated.
    accountId String
    Identifier.
    createdOn String
    When the Worker was created.
    logpush Boolean
    Whether logpush is enabled for the Worker.
    name String
    Name of the Worker.
    observability WorkerObservability
    Observability settings for the Worker.
    subdomain WorkerSubdomain
    Subdomain settings for the Worker.
    tags List<String>
    Tags associated with the Worker.
    tailConsumers List<WorkerTailConsumer>
    Other Workers that should consume logs from the Worker.
    updatedOn String
    When the Worker was most recently updated.
    accountId string
    Identifier.
    createdOn string
    When the Worker was created.
    logpush boolean
    Whether logpush is enabled for the Worker.
    name string
    Name of the Worker.
    observability WorkerObservability
    Observability settings for the Worker.
    subdomain WorkerSubdomain
    Subdomain settings for the Worker.
    tags string[]
    Tags associated with the Worker.
    tailConsumers WorkerTailConsumer[]
    Other Workers that should consume logs from the Worker.
    updatedOn string
    When the Worker was most recently updated.
    account_id str
    Identifier.
    created_on str
    When the Worker was created.
    logpush bool
    Whether logpush is enabled for the Worker.
    name str
    Name of the Worker.
    observability WorkerObservabilityArgs
    Observability settings for the Worker.
    subdomain WorkerSubdomainArgs
    Subdomain settings for the Worker.
    tags Sequence[str]
    Tags associated with the Worker.
    tail_consumers Sequence[WorkerTailConsumerArgs]
    Other Workers that should consume logs from the Worker.
    updated_on str
    When the Worker was most recently updated.
    accountId String
    Identifier.
    createdOn String
    When the Worker was created.
    logpush Boolean
    Whether logpush is enabled for the Worker.
    name String
    Name of the Worker.
    observability Property Map
    Observability settings for the Worker.
    subdomain Property Map
    Subdomain settings for the Worker.
    tags List<String>
    Tags associated with the Worker.
    tailConsumers List<Property Map>
    Other Workers that should consume logs from the Worker.
    updatedOn String
    When the Worker was most recently updated.

    Supporting Types

    WorkerObservability, WorkerObservabilityArgs

    Enabled bool
    Whether observability is enabled for the Worker.
    HeadSamplingRate double
    The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
    Logs WorkerObservabilityLogs
    Log settings for the Worker.
    Enabled bool
    Whether observability is enabled for the Worker.
    HeadSamplingRate float64
    The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
    Logs WorkerObservabilityLogs
    Log settings for the Worker.
    enabled Boolean
    Whether observability is enabled for the Worker.
    headSamplingRate Double
    The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
    logs WorkerObservabilityLogs
    Log settings for the Worker.
    enabled boolean
    Whether observability is enabled for the Worker.
    headSamplingRate number
    The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
    logs WorkerObservabilityLogs
    Log settings for the Worker.
    enabled bool
    Whether observability is enabled for the Worker.
    head_sampling_rate float
    The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
    logs WorkerObservabilityLogs
    Log settings for the Worker.
    enabled Boolean
    Whether observability is enabled for the Worker.
    headSamplingRate Number
    The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
    logs Property Map
    Log settings for the Worker.

    WorkerObservabilityLogs, WorkerObservabilityLogsArgs

    Enabled bool
    Whether logs are enabled for the Worker.
    HeadSamplingRate double
    The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
    InvocationLogs bool
    Whether invocation logs are enabled for the Worker.
    Enabled bool
    Whether logs are enabled for the Worker.
    HeadSamplingRate float64
    The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
    InvocationLogs bool
    Whether invocation logs are enabled for the Worker.
    enabled Boolean
    Whether logs are enabled for the Worker.
    headSamplingRate Double
    The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
    invocationLogs Boolean
    Whether invocation logs are enabled for the Worker.
    enabled boolean
    Whether logs are enabled for the Worker.
    headSamplingRate number
    The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
    invocationLogs boolean
    Whether invocation logs are enabled for the Worker.
    enabled bool
    Whether logs are enabled for the Worker.
    head_sampling_rate float
    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.
    enabled Boolean
    Whether logs are enabled for the Worker.
    headSamplingRate Number
    The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
    invocationLogs Boolean
    Whether invocation logs are enabled for the Worker.

    WorkerSubdomain, WorkerSubdomainArgs

    Enabled bool
    Whether the *.workers.dev subdomain is enabled for the Worker.
    PreviewsEnabled bool
    Whether preview URLs are enabled for the Worker.
    Enabled bool
    Whether the *.workers.dev subdomain is enabled for the Worker.
    PreviewsEnabled bool
    Whether preview URLs are enabled for the Worker.
    enabled Boolean
    Whether the *.workers.dev subdomain is enabled for the Worker.
    previewsEnabled Boolean
    Whether preview URLs are enabled for the Worker.
    enabled boolean
    Whether the *.workers.dev subdomain is enabled for the Worker.
    previewsEnabled boolean
    Whether preview URLs are enabled 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.
    enabled Boolean
    Whether the *.workers.dev subdomain is enabled for the Worker.
    previewsEnabled Boolean
    Whether preview URLs are enabled for the Worker.

    WorkerTailConsumer, WorkerTailConsumerArgs

    Name string
    Name of the consumer Worker.
    Name string
    Name of the consumer Worker.
    name String
    Name of the consumer Worker.
    name string
    Name of the consumer Worker.
    name str
    Name of the consumer Worker.
    name String
    Name of the consumer Worker.

    Import

    $ pulumi import cloudflare:index/worker:Worker example '<account_id>/<worker_id>'
    

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

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Cloudflare v6.8.0 published on Saturday, Aug 30, 2025 by Pulumi