1. Packages
  2. DigitalOcean
  3. API Docs
  4. DatabaseDb
DigitalOcean v4.27.0 published on Wednesday, Mar 13, 2024 by Pulumi

digitalocean.DatabaseDb

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.27.0 published on Wednesday, Mar 13, 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", {
        engine: "pg",
        version: "11",
        size: "db-s-1vcpu-1gb",
        region: "nyc1",
        nodeCount: 1,
    });
    const database_example = new digitalocean.DatabaseDb("database-example", {clusterId: postgres_example.id});
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    postgres_example = digitalocean.DatabaseCluster("postgres-example",
        engine="pg",
        version="11",
        size="db-s-1vcpu-1gb",
        region="nyc1",
        node_count=1)
    database_example = digitalocean.DatabaseDb("database-example", cluster_id=postgres_example.id)
    
    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{
    			Engine:    pulumi.String("pg"),
    			Version:   pulumi.String("11"),
    			Size:      pulumi.String("db-s-1vcpu-1gb"),
    			Region:    pulumi.String("nyc1"),
    			NodeCount: pulumi.Int(1),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDatabaseDb(ctx, "database-example", &digitalocean.DatabaseDbArgs{
    			ClusterId: postgres_example.ID(),
    		})
    		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()
        {
            Engine = "pg",
            Version = "11",
            Size = "db-s-1vcpu-1gb",
            Region = "nyc1",
            NodeCount = 1,
        });
    
        var database_example = new DigitalOcean.DatabaseDb("database-example", new()
        {
            ClusterId = postgres_example.Id,
        });
    
    });
    
    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()        
                .engine("pg")
                .version("11")
                .size("db-s-1vcpu-1gb")
                .region("nyc1")
                .nodeCount(1)
                .build());
    
            var database_example = new DatabaseDb("database-example", DatabaseDbArgs.builder()        
                .clusterId(postgres_example.id())
                .build());
    
        }
    }
    
    resources:
      database-example:
        type: digitalocean:DatabaseDb
        properties:
          clusterId: ${["postgres-example"].id}
      postgres-example:
        type: digitalocean:DatabaseCluster
        properties:
          engine: pg
          version: '11'
          size: db-s-1vcpu-1gb
          region: nyc1
          nodeCount: 1
    

    Create DatabaseDb Resource

    new DatabaseDb(name: string, args: DatabaseDbArgs, opts?: CustomResourceOptions);
    @overload
    def DatabaseDb(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   cluster_id: Optional[str] = None,
                   name: Optional[str] = None)
    @overload
    def DatabaseDb(resource_name: str,
                   args: DatabaseDbArgs,
                   opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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
    

    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.27.0 published on Wednesday, Mar 13, 2024 by Pulumi