1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. D1Database
Cloudflare v6.1.1 published on Monday, Apr 21, 2025 by Pulumi

cloudflare.D1Database

Explore with Pulumi AI

cloudflare logo
Cloudflare v6.1.1 published on Monday, Apr 21, 2025 by Pulumi

    !> When a D1 Database is replaced all the data is lost. Please ensure you have a backup of your data before replacing a D1 Database.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const exampleD1Database = new cloudflare.D1Database("example_d1_database", {
        accountId: "023e105f4ecef8ad9ca31a8372d0c353",
        name: "my-database",
        primaryLocationHint: "wnam",
    });
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    example_d1_database = cloudflare.D1Database("example_d1_database",
        account_id="023e105f4ecef8ad9ca31a8372d0c353",
        name="my-database",
        primary_location_hint="wnam")
    
    package main
    
    import (
    	"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 {
    		_, err := cloudflare.NewD1Database(ctx, "example_d1_database", &cloudflare.D1DatabaseArgs{
    			AccountId:           pulumi.String("023e105f4ecef8ad9ca31a8372d0c353"),
    			Name:                pulumi.String("my-database"),
    			PrimaryLocationHint: pulumi.String("wnam"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleD1Database = new Cloudflare.D1Database("example_d1_database", new()
        {
            AccountId = "023e105f4ecef8ad9ca31a8372d0c353",
            Name = "my-database",
            PrimaryLocationHint = "wnam",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.D1Database;
    import com.pulumi.cloudflare.D1DatabaseArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleD1Database = new D1Database("exampleD1Database", D1DatabaseArgs.builder()
                .accountId("023e105f4ecef8ad9ca31a8372d0c353")
                .name("my-database")
                .primaryLocationHint("wnam")
                .build());
    
        }
    }
    
    resources:
      exampleD1Database:
        type: cloudflare:D1Database
        name: example_d1_database
        properties:
          accountId: 023e105f4ecef8ad9ca31a8372d0c353
          name: my-database
          primaryLocationHint: wnam
    

    Create D1Database Resource

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

    Constructor syntax

    new D1Database(name: string, args: D1DatabaseArgs, opts?: CustomResourceOptions);
    @overload
    def D1Database(resource_name: str,
                   args: D1DatabaseArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def D1Database(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   account_id: Optional[str] = None,
                   name: Optional[str] = None,
                   primary_location_hint: Optional[str] = None)
    func NewD1Database(ctx *Context, name string, args D1DatabaseArgs, opts ...ResourceOption) (*D1Database, error)
    public D1Database(string name, D1DatabaseArgs args, CustomResourceOptions? opts = null)
    public D1Database(String name, D1DatabaseArgs args)
    public D1Database(String name, D1DatabaseArgs args, CustomResourceOptions options)
    
    type: cloudflare:D1Database
    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 D1DatabaseArgs
    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 D1DatabaseArgs
    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 D1DatabaseArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args D1DatabaseArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args D1DatabaseArgs
    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 d1databaseResource = new Cloudflare.D1Database("d1databaseResource", new()
    {
        AccountId = "string",
        Name = "string",
        PrimaryLocationHint = "string",
    });
    
    example, err := cloudflare.NewD1Database(ctx, "d1databaseResource", &cloudflare.D1DatabaseArgs{
    	AccountId:           pulumi.String("string"),
    	Name:                pulumi.String("string"),
    	PrimaryLocationHint: pulumi.String("string"),
    })
    
    var d1databaseResource = new D1Database("d1databaseResource", D1DatabaseArgs.builder()
        .accountId("string")
        .name("string")
        .primaryLocationHint("string")
        .build());
    
    d1database_resource = cloudflare.D1Database("d1databaseResource",
        account_id="string",
        name="string",
        primary_location_hint="string")
    
    const d1databaseResource = new cloudflare.D1Database("d1databaseResource", {
        accountId: "string",
        name: "string",
        primaryLocationHint: "string",
    });
    
    type: cloudflare:D1Database
    properties:
        accountId: string
        name: string
        primaryLocationHint: string
    

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

    AccountId string
    Account identifier tag.
    Name string
    D1 database name.
    PrimaryLocationHint string
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    AccountId string
    Account identifier tag.
    Name string
    D1 database name.
    PrimaryLocationHint string
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    accountId String
    Account identifier tag.
    name String
    D1 database name.
    primaryLocationHint String
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    accountId string
    Account identifier tag.
    name string
    D1 database name.
    primaryLocationHint string
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    account_id str
    Account identifier tag.
    name str
    D1 database name.
    primary_location_hint str
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    accountId String
    Account identifier tag.
    name String
    D1 database name.
    primaryLocationHint String
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".

    Outputs

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

    CreatedAt string
    Specifies the timestamp the resource was created as an ISO8601 string.
    FileSize double
    The D1 database's size, in bytes.
    Id string
    The provider-assigned unique ID for this managed resource.
    NumTables double
    Uuid string
    D1 database identifier (UUID).
    Version string
    CreatedAt string
    Specifies the timestamp the resource was created as an ISO8601 string.
    FileSize float64
    The D1 database's size, in bytes.
    Id string
    The provider-assigned unique ID for this managed resource.
    NumTables float64
    Uuid string
    D1 database identifier (UUID).
    Version string
    createdAt String
    Specifies the timestamp the resource was created as an ISO8601 string.
    fileSize Double
    The D1 database's size, in bytes.
    id String
    The provider-assigned unique ID for this managed resource.
    numTables Double
    uuid String
    D1 database identifier (UUID).
    version String
    createdAt string
    Specifies the timestamp the resource was created as an ISO8601 string.
    fileSize number
    The D1 database's size, in bytes.
    id string
    The provider-assigned unique ID for this managed resource.
    numTables number
    uuid string
    D1 database identifier (UUID).
    version string
    created_at str
    Specifies the timestamp the resource was created as an ISO8601 string.
    file_size float
    The D1 database's size, in bytes.
    id str
    The provider-assigned unique ID for this managed resource.
    num_tables float
    uuid str
    D1 database identifier (UUID).
    version str
    createdAt String
    Specifies the timestamp the resource was created as an ISO8601 string.
    fileSize Number
    The D1 database's size, in bytes.
    id String
    The provider-assigned unique ID for this managed resource.
    numTables Number
    uuid String
    D1 database identifier (UUID).
    version String

    Look up Existing D1Database Resource

    Get an existing D1Database 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?: D1DatabaseState, opts?: CustomResourceOptions): D1Database
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            created_at: Optional[str] = None,
            file_size: Optional[float] = None,
            name: Optional[str] = None,
            num_tables: Optional[float] = None,
            primary_location_hint: Optional[str] = None,
            uuid: Optional[str] = None,
            version: Optional[str] = None) -> D1Database
    func GetD1Database(ctx *Context, name string, id IDInput, state *D1DatabaseState, opts ...ResourceOption) (*D1Database, error)
    public static D1Database Get(string name, Input<string> id, D1DatabaseState? state, CustomResourceOptions? opts = null)
    public static D1Database get(String name, Output<String> id, D1DatabaseState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:D1Database    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
    Account identifier tag.
    CreatedAt string
    Specifies the timestamp the resource was created as an ISO8601 string.
    FileSize double
    The D1 database's size, in bytes.
    Name string
    D1 database name.
    NumTables double
    PrimaryLocationHint string
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    Uuid string
    D1 database identifier (UUID).
    Version string
    AccountId string
    Account identifier tag.
    CreatedAt string
    Specifies the timestamp the resource was created as an ISO8601 string.
    FileSize float64
    The D1 database's size, in bytes.
    Name string
    D1 database name.
    NumTables float64
    PrimaryLocationHint string
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    Uuid string
    D1 database identifier (UUID).
    Version string
    accountId String
    Account identifier tag.
    createdAt String
    Specifies the timestamp the resource was created as an ISO8601 string.
    fileSize Double
    The D1 database's size, in bytes.
    name String
    D1 database name.
    numTables Double
    primaryLocationHint String
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    uuid String
    D1 database identifier (UUID).
    version String
    accountId string
    Account identifier tag.
    createdAt string
    Specifies the timestamp the resource was created as an ISO8601 string.
    fileSize number
    The D1 database's size, in bytes.
    name string
    D1 database name.
    numTables number
    primaryLocationHint string
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    uuid string
    D1 database identifier (UUID).
    version string
    account_id str
    Account identifier tag.
    created_at str
    Specifies the timestamp the resource was created as an ISO8601 string.
    file_size float
    The D1 database's size, in bytes.
    name str
    D1 database name.
    num_tables float
    primary_location_hint str
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    uuid str
    D1 database identifier (UUID).
    version str
    accountId String
    Account identifier tag.
    createdAt String
    Specifies the timestamp the resource was created as an ISO8601 string.
    fileSize Number
    The D1 database's size, in bytes.
    name String
    D1 database name.
    numTables Number
    primaryLocationHint String
    Specify the region to create the D1 primary, if available. If this option is omitted, the D1 will be created as close as possible to the current user. Available values: "wnam", "enam", "weur", "eeur", "apac", "oc".
    uuid String
    D1 database identifier (UUID).
    version String

    Import

    $ pulumi import cloudflare:index/d1Database:D1Database example '<account_id>/<database_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.1.1 published on Monday, Apr 21, 2025 by Pulumi