1. Packages
  2. DigitalOcean
  3. API Docs
  4. DatabaseDb
DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi

digitalocean.DatabaseDb

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi

    Provides a DigitalOcean database resource. When creating a new database cluster, a default database with name defaultdb will be created. Then, this resource can be used to provide additional database inside the cluster.

    Example Usage

    Create a new PostgreSQL database

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const postgres_example = new digitalocean.DatabaseCluster("postgres-example", {
        name: "example-postgres-cluster",
        engine: "pg",
        version: "15",
        size: digitalocean.DatabaseSlug.DB_1VPCU1GB,
        region: digitalocean.Region.NYC1,
        nodeCount: 1,
    });
    const database_example = new digitalocean.DatabaseDb("database-example", {
        clusterId: postgres_example.id,
        name: "foobar",
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    postgres_example = digitalocean.DatabaseCluster("postgres-example",
        name="example-postgres-cluster",
        engine="pg",
        version="15",
        size=digitalocean.DatabaseSlug.D_B_1_VPCU1_GB,
        region=digitalocean.Region.NYC1,
        node_count=1)
    database_example = digitalocean.DatabaseDb("database-example",
        cluster_id=postgres_example.id,
        name="foobar")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := digitalocean.NewDatabaseCluster(ctx, "postgres-example", &digitalocean.DatabaseClusterArgs{
    			Name:      pulumi.String("example-postgres-cluster"),
    			Engine:    pulumi.String("pg"),
    			Version:   pulumi.String("15"),
    			Size:      pulumi.String(digitalocean.DatabaseSlug_DB_1VPCU1GB),
    			Region:    pulumi.String(digitalocean.RegionNYC1),
    			NodeCount: pulumi.Int(1),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDatabaseDb(ctx, "database-example", &digitalocean.DatabaseDbArgs{
    			ClusterId: postgres_example.ID(),
    			Name:      pulumi.String("foobar"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var postgres_example = new DigitalOcean.DatabaseCluster("postgres-example", new()
        {
            Name = "example-postgres-cluster",
            Engine = "pg",
            Version = "15",
            Size = DigitalOcean.DatabaseSlug.DB_1VPCU1GB,
            Region = DigitalOcean.Region.NYC1,
            NodeCount = 1,
        });
    
        var database_example = new DigitalOcean.DatabaseDb("database-example", new()
        {
            ClusterId = postgres_example.Id,
            Name = "foobar",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.DatabaseCluster;
    import com.pulumi.digitalocean.DatabaseClusterArgs;
    import com.pulumi.digitalocean.DatabaseDb;
    import com.pulumi.digitalocean.DatabaseDbArgs;
    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 postgres_example = new DatabaseCluster("postgres-example", DatabaseClusterArgs.builder()
                .name("example-postgres-cluster")
                .engine("pg")
                .version("15")
                .size("db-s-1vcpu-1gb")
                .region("nyc1")
                .nodeCount(1)
                .build());
    
            var database_example = new DatabaseDb("database-example", DatabaseDbArgs.builder()
                .clusterId(postgres_example.id())
                .name("foobar")
                .build());
    
        }
    }
    
    resources:
      database-example:
        type: digitalocean:DatabaseDb
        properties:
          clusterId: ${["postgres-example"].id}
          name: foobar
      postgres-example:
        type: digitalocean:DatabaseCluster
        properties:
          name: example-postgres-cluster
          engine: pg
          version: '15'
          size: db-s-1vcpu-1gb
          region: nyc1
          nodeCount: 1
    

    Create DatabaseDb Resource

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

    Constructor syntax

    new DatabaseDb(name: string, args: DatabaseDbArgs, opts?: CustomResourceOptions);
    @overload
    def DatabaseDb(resource_name: str,
                   args: DatabaseDbArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def DatabaseDb(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   cluster_id: Optional[str] = None,
                   name: Optional[str] = None)
    func NewDatabaseDb(ctx *Context, name string, args DatabaseDbArgs, opts ...ResourceOption) (*DatabaseDb, error)
    public DatabaseDb(string name, DatabaseDbArgs args, CustomResourceOptions? opts = null)
    public DatabaseDb(String name, DatabaseDbArgs args)
    public DatabaseDb(String name, DatabaseDbArgs args, CustomResourceOptions options)
    
    type: digitalocean:DatabaseDb
    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 DatabaseDbArgs
    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 DatabaseDbArgs
    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 DatabaseDbArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatabaseDbArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DatabaseDbArgs
    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 databaseDbResource = new DigitalOcean.DatabaseDb("databaseDbResource", new()
    {
        ClusterId = "string",
        Name = "string",
    });
    
    example, err := digitalocean.NewDatabaseDb(ctx, "databaseDbResource", &digitalocean.DatabaseDbArgs{
    	ClusterId: pulumi.String("string"),
    	Name:      pulumi.String("string"),
    })
    
    var databaseDbResource = new DatabaseDb("databaseDbResource", DatabaseDbArgs.builder()
        .clusterId("string")
        .name("string")
        .build());
    
    database_db_resource = digitalocean.DatabaseDb("databaseDbResource",
        cluster_id="string",
        name="string")
    
    const databaseDbResource = new digitalocean.DatabaseDb("databaseDbResource", {
        clusterId: "string",
        name: "string",
    });
    
    type: digitalocean:DatabaseDb
    properties:
        clusterId: string
        name: string
    

    DatabaseDb Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The DatabaseDb resource accepts the following input properties:

    ClusterId string
    The ID of the original source database cluster.
    Name string
    The name for the database.
    ClusterId string
    The ID of the original source database cluster.
    Name string
    The name for the database.
    clusterId String
    The ID of the original source database cluster.
    name String
    The name for the database.
    clusterId string
    The ID of the original source database cluster.
    name string
    The name for the database.
    cluster_id str
    The ID of the original source database cluster.
    name str
    The name for the database.
    clusterId String
    The ID of the original source database cluster.
    name String
    The name for the database.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DatabaseDb 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 str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing DatabaseDb Resource

    Get an existing DatabaseDb 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?: DatabaseDbState, opts?: CustomResourceOptions): DatabaseDb
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            cluster_id: Optional[str] = None,
            name: Optional[str] = None) -> DatabaseDb
    func GetDatabaseDb(ctx *Context, name string, id IDInput, state *DatabaseDbState, opts ...ResourceOption) (*DatabaseDb, error)
    public static DatabaseDb Get(string name, Input<string> id, DatabaseDbState? state, CustomResourceOptions? opts = null)
    public static DatabaseDb get(String name, Output<String> id, DatabaseDbState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    ClusterId string
    The ID of the original source database cluster.
    Name string
    The name for the database.
    ClusterId string
    The ID of the original source database cluster.
    Name string
    The name for the database.
    clusterId String
    The ID of the original source database cluster.
    name String
    The name for the database.
    clusterId string
    The ID of the original source database cluster.
    name string
    The name for the database.
    cluster_id str
    The ID of the original source database cluster.
    name str
    The name for the database.
    clusterId String
    The ID of the original source database cluster.
    name String
    The name for the database.

    Import

    Database can be imported using the id of the source database cluster

    and the name of the database joined with a comma. For example:

    $ pulumi import digitalocean:index/databaseDb:DatabaseDb database-example 245bcfd0-7f31-4ce6-a2bc-475a116cca97,foobar
    

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

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi