1. Registry
  2. Packages
  3. Cloudflare Provider
  4. API Docs
  5. WorkersKv
Viewing docs for Cloudflare v6.22.1
published on Tuesday, Oct 13, 2026 by Pulumi
cloudflare logo cloudflare logo
Viewing docs for Cloudflare v6.22.1
published on Tuesday, Oct 13, 2026 by Pulumi

    Accepted Permissions

    • Workers KV Storage Read
    • Workers KV Storage Write

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const exampleWorkersKv = new cloudflare.WorkersKv("example_workers_kv", {
        accountId: "023e105f4ecef8ad9ca31a8372d0c353",
        namespaceId: "0f2ac74b498b48028cb68387c421e279",
        keyName: "My-Key",
        value: "Some Value",
        metadata: JSON.stringify({}),
    });
    
    import pulumi
    import json
    import pulumi_cloudflare as cloudflare
    
    example_workers_kv = cloudflare.WorkersKv("example_workers_kv",
        account_id="023e105f4ecef8ad9ca31a8372d0c353",
        namespace_id="0f2ac74b498b48028cb68387c421e279",
        key_name="My-Key",
        value="Some Value",
        metadata=json.dumps({}))
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-cloudflare/sdk/v6/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = cloudflare.NewWorkersKv(ctx, "example_workers_kv", &cloudflare.WorkersKvArgs{
    			AccountId:   pulumi.String("023e105f4ecef8ad9ca31a8372d0c353"),
    			NamespaceId: pulumi.String("0f2ac74b498b48028cb68387c421e279"),
    			KeyName:     pulumi.String("My-Key"),
    			Value:       pulumi.String("Some Value"),
    			Metadata:    pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleWorkersKv = new Cloudflare.WorkersKv("example_workers_kv", new()
        {
            AccountId = "023e105f4ecef8ad9ca31a8372d0c353",
            NamespaceId = "0f2ac74b498b48028cb68387c421e279",
            KeyName = "My-Key",
            Value = "Some Value",
            Metadata = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
            }),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.WorkersKv;
    import com.pulumi.cloudflare.WorkersKvArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleWorkersKv = new WorkersKv("exampleWorkersKv", WorkersKvArgs.builder()
                .accountId("023e105f4ecef8ad9ca31a8372d0c353")
                .namespaceId("0f2ac74b498b48028cb68387c421e279")
                .keyName("My-Key")
                .value("Some Value")
                .metadata(serializeJson(
                    jsonObject(
    
                    )))
                .build());
    
        }
    }
    
    resources:
      exampleWorkersKv:
        type: cloudflare:WorkersKv
        name: example_workers_kv
        properties:
          accountId: 023e105f4ecef8ad9ca31a8372d0c353
          namespaceId: 0f2ac74b498b48028cb68387c421e279
          keyName: My-Key
          value: Some Value
          metadata:
            fn::toJSON: {}
    
    terraform {
      required_providers {
        cloudflare = {
          source = "pulumi/cloudflare"
        }
      }
    }
    
    resource "cloudflare_workers_kv" "example_workers_kv" {
      lifecycle {
        create_before_destroy = true
      }
      account_id   = "023e105f4ecef8ad9ca31a8372d0c353"
      namespace_id = "0f2ac74b498b48028cb68387c421e279"
      key_name     = "My-Key"
      value        = "Some Value"
      metadata     = jsonencode({})
    }
    

    Create WorkersKv Resource

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

    Constructor syntax

    new WorkersKv(name: string, args: WorkersKvArgs, opts?: CustomResourceOptions);
    @overload
    def WorkersKv(resource_name: str,
                  args: WorkersKvArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def WorkersKv(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  account_id: Optional[str] = None,
                  key_name: Optional[str] = None,
                  namespace_id: Optional[str] = None,
                  value: Optional[str] = None,
                  expiration: Optional[float] = None,
                  expiration_ttl: Optional[float] = None,
                  metadata: Optional[str] = None)
    func NewWorkersKv(ctx *Context, name string, args WorkersKvArgs, opts ...ResourceOption) (*WorkersKv, error)
    public WorkersKv(string name, WorkersKvArgs args, CustomResourceOptions? opts = null)
    public WorkersKv(String name, WorkersKvArgs args)
    public WorkersKv(String name, WorkersKvArgs args, CustomResourceOptions options)
    
    type: cloudflare:WorkersKv
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "cloudflare_workers_kv" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args WorkersKvArgs
    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 WorkersKvArgs
    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 WorkersKvArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args WorkersKvArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args WorkersKvArgs
    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 workersKvResource = new Cloudflare.WorkersKv("workersKvResource", new()
    {
        AccountId = "string",
        KeyName = "string",
        NamespaceId = "string",
        Value = "string",
        Expiration = 0.0,
        ExpirationTtl = 0.0,
        Metadata = "string",
    });
    
    example, err := cloudflare.NewWorkersKv(ctx, "workersKvResource", &cloudflare.WorkersKvArgs{
    	AccountId:     pulumi.String("string"),
    	KeyName:       pulumi.String("string"),
    	NamespaceId:   pulumi.String("string"),
    	Value:         pulumi.String("string"),
    	Expiration:    pulumi.Float64(0),
    	ExpirationTtl: pulumi.Float64(0),
    	Metadata:      pulumi.String("string"),
    })
    
    resource "cloudflare_workers_kv" "workersKvResource" {
      lifecycle {
        create_before_destroy = true
      }
      account_id     = "string"
      key_name       = "string"
      namespace_id   = "string"
      value          = "string"
      expiration     = 0
      expiration_ttl = 0
      metadata       = "string"
    }
    
    var workersKvResource = new WorkersKv("workersKvResource", WorkersKvArgs.builder()
        .accountId("string")
        .keyName("string")
        .namespaceId("string")
        .value("string")
        .expiration(0.0)
        .expirationTtl(0.0)
        .metadata("string")
        .build());
    
    workers_kv_resource = cloudflare.WorkersKv("workersKvResource",
        account_id="string",
        key_name="string",
        namespace_id="string",
        value="string",
        expiration=float(0),
        expiration_ttl=float(0),
        metadata="string")
    
    const workersKvResource = new cloudflare.WorkersKv("workersKvResource", {
        accountId: "string",
        keyName: "string",
        namespaceId: "string",
        value: "string",
        expiration: 0,
        expirationTtl: 0,
        metadata: "string",
    });
    
    type: cloudflare:WorkersKv
    properties:
        accountId: string
        expiration: 0
        expirationTtl: 0
        keyName: string
        metadata: string
        namespaceId: string
        value: string
    

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

    AccountId string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    KeyName string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    NamespaceId string
    ID of the Workers KV namespace.
    Value string
    A byte sequence to be stored, up to 25 MiB in length.
    Expiration double
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    ExpirationTtl double
    Expires the key after a number of seconds. Must be at least 60.
    Metadata string
    Associates arbitrary JSON data with a key/value pair.
    AccountId string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    KeyName string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    NamespaceId string
    ID of the Workers KV namespace.
    Value string
    A byte sequence to be stored, up to 25 MiB in length.
    Expiration float64
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    ExpirationTtl float64
    Expires the key after a number of seconds. Must be at least 60.
    Metadata string
    Associates arbitrary JSON data with a key/value pair.
    account_id string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    key_name string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    namespace_id string
    ID of the Workers KV namespace.
    value string
    A byte sequence to be stored, up to 25 MiB in length.
    expiration number
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expiration_ttl number
    Expires the key after a number of seconds. Must be at least 60.
    metadata string
    Associates arbitrary JSON data with a key/value pair.
    accountId String
    ID of the Cloudflare account that owns the Workers KV namespaces.
    keyName String
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    namespaceId String
    ID of the Workers KV namespace.
    value String
    A byte sequence to be stored, up to 25 MiB in length.
    expiration Double
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expirationTtl Double
    Expires the key after a number of seconds. Must be at least 60.
    metadata String
    Associates arbitrary JSON data with a key/value pair.
    accountId string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    keyName string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    namespaceId string
    ID of the Workers KV namespace.
    value string
    A byte sequence to be stored, up to 25 MiB in length.
    expiration number
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expirationTtl number
    Expires the key after a number of seconds. Must be at least 60.
    metadata string
    Associates arbitrary JSON data with a key/value pair.
    account_id str
    ID of the Cloudflare account that owns the Workers KV namespaces.
    key_name str
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    namespace_id str
    ID of the Workers KV namespace.
    value str
    A byte sequence to be stored, up to 25 MiB in length.
    expiration float
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expiration_ttl float
    Expires the key after a number of seconds. Must be at least 60.
    metadata str
    Associates arbitrary JSON data with a key/value pair.
    accountId String
    ID of the Cloudflare account that owns the Workers KV namespaces.
    keyName String
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    namespaceId String
    ID of the Workers KV namespace.
    value String
    A byte sequence to be stored, up to 25 MiB in length.
    expiration Number
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expirationTtl Number
    Expires the key after a number of seconds. Must be at least 60.
    metadata String
    Associates arbitrary JSON data with a key/value pair.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing WorkersKv Resource

    Get an existing WorkersKv 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?: WorkersKvState, opts?: CustomResourceOptions): WorkersKv
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            expiration: Optional[float] = None,
            expiration_ttl: Optional[float] = None,
            key_name: Optional[str] = None,
            metadata: Optional[str] = None,
            namespace_id: Optional[str] = None,
            value: Optional[str] = None) -> WorkersKv
    func GetWorkersKv(ctx *Context, name string, id IDInput, state *WorkersKvState, opts ...ResourceOption) (*WorkersKv, error)
    public static WorkersKv Get(string name, Input<string> id, WorkersKvState? state, CustomResourceOptions? opts = null)
    public static WorkersKv get(String name, Output<String> id, WorkersKvState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:WorkersKv    get:      id: ${id}
    import {
      to = cloudflare_workers_kv.example
      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
    ID of the Cloudflare account that owns the Workers KV namespaces.
    Expiration double
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    ExpirationTtl double
    Expires the key after a number of seconds. Must be at least 60.
    KeyName string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    Metadata string
    Associates arbitrary JSON data with a key/value pair.
    NamespaceId string
    ID of the Workers KV namespace.
    Value string
    A byte sequence to be stored, up to 25 MiB in length.
    AccountId string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    Expiration float64
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    ExpirationTtl float64
    Expires the key after a number of seconds. Must be at least 60.
    KeyName string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    Metadata string
    Associates arbitrary JSON data with a key/value pair.
    NamespaceId string
    ID of the Workers KV namespace.
    Value string
    A byte sequence to be stored, up to 25 MiB in length.
    account_id string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    expiration number
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expiration_ttl number
    Expires the key after a number of seconds. Must be at least 60.
    key_name string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    metadata string
    Associates arbitrary JSON data with a key/value pair.
    namespace_id string
    ID of the Workers KV namespace.
    value string
    A byte sequence to be stored, up to 25 MiB in length.
    accountId String
    ID of the Cloudflare account that owns the Workers KV namespaces.
    expiration Double
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expirationTtl Double
    Expires the key after a number of seconds. Must be at least 60.
    keyName String
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    metadata String
    Associates arbitrary JSON data with a key/value pair.
    namespaceId String
    ID of the Workers KV namespace.
    value String
    A byte sequence to be stored, up to 25 MiB in length.
    accountId string
    ID of the Cloudflare account that owns the Workers KV namespaces.
    expiration number
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expirationTtl number
    Expires the key after a number of seconds. Must be at least 60.
    keyName string
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    metadata string
    Associates arbitrary JSON data with a key/value pair.
    namespaceId string
    ID of the Workers KV namespace.
    value string
    A byte sequence to be stored, up to 25 MiB in length.
    account_id str
    ID of the Cloudflare account that owns the Workers KV namespaces.
    expiration float
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expiration_ttl float
    Expires the key after a number of seconds. Must be at least 60.
    key_name str
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    metadata str
    Associates arbitrary JSON data with a key/value pair.
    namespace_id str
    ID of the Workers KV namespace.
    value str
    A byte sequence to be stored, up to 25 MiB in length.
    accountId String
    ID of the Cloudflare account that owns the Workers KV namespaces.
    expiration Number
    Expires the key at a certain time, measured in number of seconds since the UNIX epoch.
    expirationTtl Number
    Expires the key after a number of seconds. Must be at least 60.
    keyName String
    A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.
    metadata String
    Associates arbitrary JSON data with a key/value pair.
    namespaceId String
    ID of the Workers KV namespace.
    value String
    A byte sequence to be stored, up to 25 MiB in length.

    Import

    $ pulumi import cloudflare:index/workersKv:WorkersKv example '<account_id>/<namespace_id>/<key_name>'
    

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

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo cloudflare logo
    Viewing docs for Cloudflare v6.22.1
    published on Tuesday, Oct 13, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial