1. Packages
  2. CockroachDB Cloud
  3. API Docs
  4. Database
CockroachDB v0.9.4 published on Friday, Mar 21, 2025 by pulumiverse

cockroach.Database

Explore with Pulumi AI

CockroachDB database.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as cockroach from "@pulumiverse/cockroach";

const config = new pulumi.Config();
const clusterId = config.require("clusterId");
const cockroach = new cockroach.Database("cockroach", {
    name: "example-database",
    clusterId: clusterId,
});
Copy
import pulumi
import pulumiverse_cockroach as cockroach

config = pulumi.Config()
cluster_id = config.require("clusterId")
cockroach = cockroach.Database("cockroach",
    name="example-database",
    cluster_id=cluster_id)
Copy
package main

import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
	"github.com/pulumiverse/pulumi-cockroach/sdk/go/cockroach"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		clusterId := cfg.Require("clusterId")
		_, err := cockroach.NewDatabase(ctx, "cockroach", &cockroach.DatabaseArgs{
			Name:      pulumi.String("example-database"),
			ClusterId: pulumi.String(clusterId),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cockroach = Pulumiverse.Cockroach;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var clusterId = config.Require("clusterId");
    var cockroach = new Cockroach.Database("cockroach", new()
    {
        Name = "example-database",
        ClusterId = clusterId,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cockroach.Database;
import com.pulumi.cockroach.DatabaseArgs;
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) {
        final var config = ctx.config();
        final var clusterId = config.get("clusterId");
        var cockroach = new Database("cockroach", DatabaseArgs.builder()
            .name("example-database")
            .clusterId(clusterId)
            .build());

    }
}
Copy
configuration:
  clusterId:
    type: string
resources:
  cockroach:
    type: cockroach:Database
    properties:
      name: example-database
      clusterId: ${clusterId}
Copy

Create Database Resource

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

Constructor syntax

new Database(name: string, args: DatabaseArgs, opts?: CustomResourceOptions);
@overload
def Database(resource_name: str,
             args: DatabaseArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def Database(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             cluster_id: Optional[str] = None,
             name: Optional[str] = None)
func NewDatabase(ctx *Context, name string, args DatabaseArgs, opts ...ResourceOption) (*Database, error)
public Database(string name, DatabaseArgs args, CustomResourceOptions? opts = null)
public Database(String name, DatabaseArgs args)
public Database(String name, DatabaseArgs args, CustomResourceOptions options)
type: cockroach:Database
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DatabaseArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DatabaseArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DatabaseArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DatabaseArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DatabaseArgs
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 databaseResource = new Cockroach.Database("databaseResource", new()
{
    ClusterId = "string",
    Name = "string",
});
Copy
example, err := cockroach.NewDatabase(ctx, "databaseResource", &cockroach.DatabaseArgs{
	ClusterId: pulumi.String("string"),
	Name:      pulumi.String("string"),
})
Copy
var databaseResource = new Database("databaseResource", DatabaseArgs.builder()
    .clusterId("string")
    .name("string")
    .build());
Copy
database_resource = cockroach.Database("databaseResource",
    cluster_id="string",
    name="string")
Copy
const databaseResource = new cockroach.Database("databaseResource", {
    clusterId: "string",
    name: "string",
});
Copy
type: cockroach:Database
properties:
    clusterId: string
    name: string
Copy

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

ClusterId This property is required. string
ID of the cluster the database belongs to.
Name string
Database name.
ClusterId This property is required. string
ID of the cluster the database belongs to.
Name string
Database name.
clusterId This property is required. String
ID of the cluster the database belongs to.
name String
Database name.
clusterId This property is required. string
ID of the cluster the database belongs to.
name string
Database name.
cluster_id This property is required. str
ID of the cluster the database belongs to.
name str
Database name.
clusterId This property is required. String
ID of the cluster the database belongs to.
name String
Database name.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
TableCount int
Number of tables in the database.
Id string
The provider-assigned unique ID for this managed resource.
TableCount int
Number of tables in the database.
id String
The provider-assigned unique ID for this managed resource.
tableCount Integer
Number of tables in the database.
id string
The provider-assigned unique ID for this managed resource.
tableCount number
Number of tables in the database.
id str
The provider-assigned unique ID for this managed resource.
table_count int
Number of tables in the database.
id String
The provider-assigned unique ID for this managed resource.
tableCount Number
Number of tables in the database.

Look up Existing Database Resource

Get an existing Database 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?: DatabaseState, opts?: CustomResourceOptions): Database
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cluster_id: Optional[str] = None,
        name: Optional[str] = None,
        table_count: Optional[int] = None) -> Database
func GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)
public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)
public static Database get(String name, Output<String> id, DatabaseState state, CustomResourceOptions options)
resources:  _:    type: cockroach:Database    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
ClusterId string
ID of the cluster the database belongs to.
Name string
Database name.
TableCount int
Number of tables in the database.
ClusterId string
ID of the cluster the database belongs to.
Name string
Database name.
TableCount int
Number of tables in the database.
clusterId String
ID of the cluster the database belongs to.
name String
Database name.
tableCount Integer
Number of tables in the database.
clusterId string
ID of the cluster the database belongs to.
name string
Database name.
tableCount number
Number of tables in the database.
cluster_id str
ID of the cluster the database belongs to.
name str
Database name.
table_count int
Number of tables in the database.
clusterId String
ID of the cluster the database belongs to.
name String
Database name.
tableCount Number
Number of tables in the database.

Import

format: :

$ pulumi import cockroach:index/database:Database my_database 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:mydatabase
Copy

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

Package Details

Repository
cockroach pulumiverse/pulumi-cockroach
License
Apache-2.0
Notes
This Pulumi package is based on the cockroach Terraform Provider.