1. Packages
  2. DigitalOcean Provider
  3. API Docs
  4. DatabaseConnectionPool
DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi

digitalocean.DatabaseConnectionPool

Explore with Pulumi AI

Provides a DigitalOcean database connection pool resource.

Example Usage

Create a new PostgreSQL database connection pool

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 pool_01 = new digitalocean.DatabaseConnectionPool("pool-01", {
    clusterId: postgres_example.id,
    name: "pool-01",
    mode: "transaction",
    size: 20,
    dbName: "defaultdb",
    user: "doadmin",
});
Copy
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)
pool_01 = digitalocean.DatabaseConnectionPool("pool-01",
    cluster_id=postgres_example.id,
    name="pool-01",
    mode="transaction",
    size=20,
    db_name="defaultdb",
    user="doadmin")
Copy
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 {
		postgres_example, 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.NewDatabaseConnectionPool(ctx, "pool-01", &digitalocean.DatabaseConnectionPoolArgs{
			ClusterId: postgres_example.ID(),
			Name:      pulumi.String("pool-01"),
			Mode:      pulumi.String("transaction"),
			Size:      pulumi.Int(20),
			DbName:    pulumi.String("defaultdb"),
			User:      pulumi.String("doadmin"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 pool_01 = new DigitalOcean.DatabaseConnectionPool("pool-01", new()
    {
        ClusterId = postgres_example.Id,
        Name = "pool-01",
        Mode = "transaction",
        Size = 20,
        DbName = "defaultdb",
        User = "doadmin",
    });

});
Copy
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.DatabaseConnectionPool;
import com.pulumi.digitalocean.DatabaseConnectionPoolArgs;
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 pool_01 = new DatabaseConnectionPool("pool-01", DatabaseConnectionPoolArgs.builder()
            .clusterId(postgres_example.id())
            .name("pool-01")
            .mode("transaction")
            .size(20)
            .dbName("defaultdb")
            .user("doadmin")
            .build());

    }
}
Copy
resources:
  pool-01:
    type: digitalocean:DatabaseConnectionPool
    properties:
      clusterId: ${["postgres-example"].id}
      name: pool-01
      mode: transaction
      size: 20
      dbName: defaultdb
      user: doadmin
  postgres-example:
    type: digitalocean:DatabaseCluster
    properties:
      name: example-postgres-cluster
      engine: pg
      version: '15'
      size: db-s-1vcpu-1gb
      region: nyc1
      nodeCount: 1
Copy

Create DatabaseConnectionPool Resource

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

Constructor syntax

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

@overload
def DatabaseConnectionPool(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           cluster_id: Optional[str] = None,
                           db_name: Optional[str] = None,
                           mode: Optional[str] = None,
                           size: Optional[int] = None,
                           name: Optional[str] = None,
                           user: Optional[str] = None)
func NewDatabaseConnectionPool(ctx *Context, name string, args DatabaseConnectionPoolArgs, opts ...ResourceOption) (*DatabaseConnectionPool, error)
public DatabaseConnectionPool(string name, DatabaseConnectionPoolArgs args, CustomResourceOptions? opts = null)
public DatabaseConnectionPool(String name, DatabaseConnectionPoolArgs args)
public DatabaseConnectionPool(String name, DatabaseConnectionPoolArgs args, CustomResourceOptions options)
type: digitalocean:DatabaseConnectionPool
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. DatabaseConnectionPoolArgs
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. DatabaseConnectionPoolArgs
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. DatabaseConnectionPoolArgs
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. DatabaseConnectionPoolArgs
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. DatabaseConnectionPoolArgs
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 databaseConnectionPoolResource = new DigitalOcean.DatabaseConnectionPool("databaseConnectionPoolResource", new()
{
    ClusterId = "string",
    DbName = "string",
    Mode = "string",
    Size = 0,
    Name = "string",
    User = "string",
});
Copy
example, err := digitalocean.NewDatabaseConnectionPool(ctx, "databaseConnectionPoolResource", &digitalocean.DatabaseConnectionPoolArgs{
	ClusterId: pulumi.String("string"),
	DbName:    pulumi.String("string"),
	Mode:      pulumi.String("string"),
	Size:      pulumi.Int(0),
	Name:      pulumi.String("string"),
	User:      pulumi.String("string"),
})
Copy
var databaseConnectionPoolResource = new DatabaseConnectionPool("databaseConnectionPoolResource", DatabaseConnectionPoolArgs.builder()
    .clusterId("string")
    .dbName("string")
    .mode("string")
    .size(0)
    .name("string")
    .user("string")
    .build());
Copy
database_connection_pool_resource = digitalocean.DatabaseConnectionPool("databaseConnectionPoolResource",
    cluster_id="string",
    db_name="string",
    mode="string",
    size=0,
    name="string",
    user="string")
Copy
const databaseConnectionPoolResource = new digitalocean.DatabaseConnectionPool("databaseConnectionPoolResource", {
    clusterId: "string",
    dbName: "string",
    mode: "string",
    size: 0,
    name: "string",
    user: "string",
});
Copy
type: digitalocean:DatabaseConnectionPool
properties:
    clusterId: string
    dbName: string
    mode: string
    name: string
    size: 0
    user: string
Copy

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

ClusterId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
DbName
This property is required.
Changes to this property will trigger replacement.
string
The database for use with the connection pool.
Mode
This property is required.
Changes to this property will trigger replacement.
string
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
Size
This property is required.
Changes to this property will trigger replacement.
int
The desired size of the PGBouncer connection pool.
Name Changes to this property will trigger replacement. string
The name for the database connection pool.
User Changes to this property will trigger replacement. string
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
ClusterId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
DbName
This property is required.
Changes to this property will trigger replacement.
string
The database for use with the connection pool.
Mode
This property is required.
Changes to this property will trigger replacement.
string
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
Size
This property is required.
Changes to this property will trigger replacement.
int
The desired size of the PGBouncer connection pool.
Name Changes to this property will trigger replacement. string
The name for the database connection pool.
User Changes to this property will trigger replacement. string
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
clusterId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
dbName
This property is required.
Changes to this property will trigger replacement.
String
The database for use with the connection pool.
mode
This property is required.
Changes to this property will trigger replacement.
String
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
size
This property is required.
Changes to this property will trigger replacement.
Integer
The desired size of the PGBouncer connection pool.
name Changes to this property will trigger replacement. String
The name for the database connection pool.
user Changes to this property will trigger replacement. String
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
clusterId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
dbName
This property is required.
Changes to this property will trigger replacement.
string
The database for use with the connection pool.
mode
This property is required.
Changes to this property will trigger replacement.
string
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
size
This property is required.
Changes to this property will trigger replacement.
number
The desired size of the PGBouncer connection pool.
name Changes to this property will trigger replacement. string
The name for the database connection pool.
user Changes to this property will trigger replacement. string
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
cluster_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
db_name
This property is required.
Changes to this property will trigger replacement.
str
The database for use with the connection pool.
mode
This property is required.
Changes to this property will trigger replacement.
str
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
size
This property is required.
Changes to this property will trigger replacement.
int
The desired size of the PGBouncer connection pool.
name Changes to this property will trigger replacement. str
The name for the database connection pool.
user Changes to this property will trigger replacement. str
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
clusterId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
dbName
This property is required.
Changes to this property will trigger replacement.
String
The database for use with the connection pool.
mode
This property is required.
Changes to this property will trigger replacement.
String
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
size
This property is required.
Changes to this property will trigger replacement.
Number
The desired size of the PGBouncer connection pool.
name Changes to this property will trigger replacement. String
The name for the database connection pool.
user Changes to this property will trigger replacement. String
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.

Outputs

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

Host string
The hostname used to connect to the database connection pool.
Id string
The provider-assigned unique ID for this managed resource.
Password string
Password for the connection pool's user.
Port int
Network port that the database connection pool is listening on.
PrivateHost string
Same as host, but only accessible from resources within the account and in the same region.
PrivateUri string
Same as uri, but only accessible from resources within the account and in the same region.
Uri string
The full URI for connecting to the database connection pool.
Host string
The hostname used to connect to the database connection pool.
Id string
The provider-assigned unique ID for this managed resource.
Password string
Password for the connection pool's user.
Port int
Network port that the database connection pool is listening on.
PrivateHost string
Same as host, but only accessible from resources within the account and in the same region.
PrivateUri string
Same as uri, but only accessible from resources within the account and in the same region.
Uri string
The full URI for connecting to the database connection pool.
host String
The hostname used to connect to the database connection pool.
id String
The provider-assigned unique ID for this managed resource.
password String
Password for the connection pool's user.
port Integer
Network port that the database connection pool is listening on.
privateHost String
Same as host, but only accessible from resources within the account and in the same region.
privateUri String
Same as uri, but only accessible from resources within the account and in the same region.
uri String
The full URI for connecting to the database connection pool.
host string
The hostname used to connect to the database connection pool.
id string
The provider-assigned unique ID for this managed resource.
password string
Password for the connection pool's user.
port number
Network port that the database connection pool is listening on.
privateHost string
Same as host, but only accessible from resources within the account and in the same region.
privateUri string
Same as uri, but only accessible from resources within the account and in the same region.
uri string
The full URI for connecting to the database connection pool.
host str
The hostname used to connect to the database connection pool.
id str
The provider-assigned unique ID for this managed resource.
password str
Password for the connection pool's user.
port int
Network port that the database connection pool is listening on.
private_host str
Same as host, but only accessible from resources within the account and in the same region.
private_uri str
Same as uri, but only accessible from resources within the account and in the same region.
uri str
The full URI for connecting to the database connection pool.
host String
The hostname used to connect to the database connection pool.
id String
The provider-assigned unique ID for this managed resource.
password String
Password for the connection pool's user.
port Number
Network port that the database connection pool is listening on.
privateHost String
Same as host, but only accessible from resources within the account and in the same region.
privateUri String
Same as uri, but only accessible from resources within the account and in the same region.
uri String
The full URI for connecting to the database connection pool.

Look up Existing DatabaseConnectionPool Resource

Get an existing DatabaseConnectionPool 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?: DatabaseConnectionPoolState, opts?: CustomResourceOptions): DatabaseConnectionPool
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cluster_id: Optional[str] = None,
        db_name: Optional[str] = None,
        host: Optional[str] = None,
        mode: Optional[str] = None,
        name: Optional[str] = None,
        password: Optional[str] = None,
        port: Optional[int] = None,
        private_host: Optional[str] = None,
        private_uri: Optional[str] = None,
        size: Optional[int] = None,
        uri: Optional[str] = None,
        user: Optional[str] = None) -> DatabaseConnectionPool
func GetDatabaseConnectionPool(ctx *Context, name string, id IDInput, state *DatabaseConnectionPoolState, opts ...ResourceOption) (*DatabaseConnectionPool, error)
public static DatabaseConnectionPool Get(string name, Input<string> id, DatabaseConnectionPoolState? state, CustomResourceOptions? opts = null)
public static DatabaseConnectionPool get(String name, Output<String> id, DatabaseConnectionPoolState state, CustomResourceOptions options)
resources:  _:    type: digitalocean:DatabaseConnectionPool    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 Changes to this property will trigger replacement. string
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
DbName Changes to this property will trigger replacement. string
The database for use with the connection pool.
Host string
The hostname used to connect to the database connection pool.
Mode Changes to this property will trigger replacement. string
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
Name Changes to this property will trigger replacement. string
The name for the database connection pool.
Password string
Password for the connection pool's user.
Port int
Network port that the database connection pool is listening on.
PrivateHost string
Same as host, but only accessible from resources within the account and in the same region.
PrivateUri string
Same as uri, but only accessible from resources within the account and in the same region.
Size Changes to this property will trigger replacement. int
The desired size of the PGBouncer connection pool.
Uri string
The full URI for connecting to the database connection pool.
User Changes to this property will trigger replacement. string
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
ClusterId Changes to this property will trigger replacement. string
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
DbName Changes to this property will trigger replacement. string
The database for use with the connection pool.
Host string
The hostname used to connect to the database connection pool.
Mode Changes to this property will trigger replacement. string
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
Name Changes to this property will trigger replacement. string
The name for the database connection pool.
Password string
Password for the connection pool's user.
Port int
Network port that the database connection pool is listening on.
PrivateHost string
Same as host, but only accessible from resources within the account and in the same region.
PrivateUri string
Same as uri, but only accessible from resources within the account and in the same region.
Size Changes to this property will trigger replacement. int
The desired size of the PGBouncer connection pool.
Uri string
The full URI for connecting to the database connection pool.
User Changes to this property will trigger replacement. string
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
clusterId Changes to this property will trigger replacement. String
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
dbName Changes to this property will trigger replacement. String
The database for use with the connection pool.
host String
The hostname used to connect to the database connection pool.
mode Changes to this property will trigger replacement. String
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
name Changes to this property will trigger replacement. String
The name for the database connection pool.
password String
Password for the connection pool's user.
port Integer
Network port that the database connection pool is listening on.
privateHost String
Same as host, but only accessible from resources within the account and in the same region.
privateUri String
Same as uri, but only accessible from resources within the account and in the same region.
size Changes to this property will trigger replacement. Integer
The desired size of the PGBouncer connection pool.
uri String
The full URI for connecting to the database connection pool.
user Changes to this property will trigger replacement. String
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
clusterId Changes to this property will trigger replacement. string
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
dbName Changes to this property will trigger replacement. string
The database for use with the connection pool.
host string
The hostname used to connect to the database connection pool.
mode Changes to this property will trigger replacement. string
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
name Changes to this property will trigger replacement. string
The name for the database connection pool.
password string
Password for the connection pool's user.
port number
Network port that the database connection pool is listening on.
privateHost string
Same as host, but only accessible from resources within the account and in the same region.
privateUri string
Same as uri, but only accessible from resources within the account and in the same region.
size Changes to this property will trigger replacement. number
The desired size of the PGBouncer connection pool.
uri string
The full URI for connecting to the database connection pool.
user Changes to this property will trigger replacement. string
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
cluster_id Changes to this property will trigger replacement. str
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
db_name Changes to this property will trigger replacement. str
The database for use with the connection pool.
host str
The hostname used to connect to the database connection pool.
mode Changes to this property will trigger replacement. str
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
name Changes to this property will trigger replacement. str
The name for the database connection pool.
password str
Password for the connection pool's user.
port int
Network port that the database connection pool is listening on.
private_host str
Same as host, but only accessible from resources within the account and in the same region.
private_uri str
Same as uri, but only accessible from resources within the account and in the same region.
size Changes to this property will trigger replacement. int
The desired size of the PGBouncer connection pool.
uri str
The full URI for connecting to the database connection pool.
user Changes to this property will trigger replacement. str
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.
clusterId Changes to this property will trigger replacement. String
The ID of the source database cluster. Note: This must be a PostgreSQL cluster.
dbName Changes to this property will trigger replacement. String
The database for use with the connection pool.
host String
The hostname used to connect to the database connection pool.
mode Changes to this property will trigger replacement. String
The PGBouncer transaction mode for the connection pool. The allowed values are session, transaction, and statement.
name Changes to this property will trigger replacement. String
The name for the database connection pool.
password String
Password for the connection pool's user.
port Number
Network port that the database connection pool is listening on.
privateHost String
Same as host, but only accessible from resources within the account and in the same region.
privateUri String
Same as uri, but only accessible from resources within the account and in the same region.
size Changes to this property will trigger replacement. Number
The desired size of the PGBouncer connection pool.
uri String
The full URI for connecting to the database connection pool.
user Changes to this property will trigger replacement. String
The name of the database user for use with the connection pool. When excluded, all sessions connect to the database as the inbound user.

Import

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

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

$ pulumi import digitalocean:index/databaseConnectionPool:DatabaseConnectionPool pool-01 245bcfd0-7f31-4ce6-a2bc-475a116cca97,pool-01
Copy

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.